Skip to content

Commit

Permalink
Merge branch 'master' into fix/dicom-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre authored May 1, 2024
2 parents 45c4846 + 4d346ff commit a9d20e9
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 13 deletions.
20 changes: 17 additions & 3 deletions kube/services/argo-events/workflows/sensor-created.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,22 @@ spec:
args:
- "-c"
- |
#!/bin/bash
if [ -z "$PROVISIONER_TEMPLATE" ]; then
PROVISIONER_TEMPLATE="provisioner.yaml"
fi
if [ -z "$AWSNODETEMPLATE_TEMPLATE" ]; then
AWSNODETEMPLATE_TEMPLATE="nodetemplate.yaml"
fi
if ! kubectl get awsnodetemplate workflow-$WORKFLOW_NAME >/dev/null 2>&1; then
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" | kubectl apply -f -
sed -e "s/WORKFLOW_NAME/$WORKFLOW_NAME/" -e "s/GEN3_USERNAME/$GEN3_USERNAME/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$AWSNODETEMPLATE_TEMPLATE" | kubectl apply -f -
fi
if ! kubectl get provisioner workflow-$WORKFLOW_NAME >/dev/null 2>&1; then
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" | kubectl apply -f -
sed -e "s/WORKFLOW_NAME/$WORKFLOW_NAME/" -e "s/GEN3_USERNAME/$GEN3_USERNAME/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$PROVISIONER_TEMPLATE" | kubectl apply -f -
fi
env:
- name: WORKFLOW_NAME
Expand All @@ -76,9 +86,13 @@ spec:
configMapKeyRef:
name: environment
key: environment
- name: PROVISIONER_TEMPLATE
value: /manifests/provisioner.yaml
- name: AWSNODETEMPLATE_TEMPLATE
value: /manifests/nodetemplate.yaml
volumeMounts:
- name: karpenter-templates-volume
mountPath: /home/manifests
mountPath: /manifests
volumes:
- name: karpenter-templates-volume
configMap:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: karpenter-reconciler-cronjob-va-testing
namespace: argo-events
spec:
schedule: "*/5 * * * *"
jobTemplate:
spec:
template:
metadata:
labels:
app: gen3job
spec:
serviceAccount: karpenter-reconciler
volumes:
- name: karpenter-templates-volume
configMap:
name: karpenter-templates
containers:
- name: karpenter-reconciler
image: quay.io/cdis/awshelper
volumeMounts:
- name: karpenter-templates-volume
mountPath: /manifests
env:
- name: PROVISIONER_TEMPLATE
value: /manifests/provisioner.yaml
- name: AWSNODETEMPLATE_TEMPLATE
value: /manifests/nodetemplate.yaml
command: ["/bin/bash"]
args:
- "-c"
- |
#!/bin/bash
if [ -z "$PROVISIONER_TEMPLATE" ]; then
PROVISIONER_TEMPLATE="provisioner.yaml"
fi
if [ -z "$AWSNODETEMPLATE_TEMPLATE" ]; then
AWSNODETEMPLATE_TEMPLATE="nodetemplate.yaml"
fi
ENVIRONMENT=$(kubectl -n va-testing get configmap global -o jsonpath="{.data.environment}")
WORKFLOWS=$(kubectl get workflows -n argo -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{.metadata.labels.gen3username}{"\n"}')
WORKFLOW_ARRAY=()
while IFS= read -r line; do
WORKFLOW_ARRAY+=("$line")
done <<< "$WORKFLOWS"
for workflow in "${WORKFLOW_ARRAY[@]}"
do
echo "Running loop for workflow: $workflow"
workflow_name=$(echo "$workflow" | awk '{print $1}')
workflow_user=$(echo "$workflow" | awk '{print $2}')
if ! kubectl get awsnodetemplate workflow-$workflow_name >/dev/null 2>&1; then
echo "No awsnodetemplate found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$AWSNODETEMPLATE_TEMPLATE" | kubectl apply -f -
fi
if ! kubectl get provisioner workflow-$workflow_name >/dev/null 2>&1; then
echo "No provisioner found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$PROVISIONER_TEMPLATE" | kubectl apply -f -
fi
done
restartPolicy: OnFailure
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,32 @@ spec:
ENVIRONMENT=$(kubectl -n default get configmap global -o jsonpath="{.data.environment}")
RAW_WORKFLOWS=$(kubectl get workflows -n argo -o yaml)
WORKFLOWS=$(echo "${RAW_WORKFLOWS}" | yq -r '.items[] | [.metadata.name, .metadata.labels.gen3username] | join(" ")')
WORKFLOWS=$(kubectl get workflows -n argo -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{.metadata.labels.gen3username}{"\n"}')
WORKFLOW_ARRAY=()
while IFS= read -r line; do
WORKFLOW_ARRAY+=("$line")
done <<< "$WORKFLOWS"
echo $WORKFLOWS
for workflow in "${WORKFLOW_ARRAY[@]}"
do
workflow_name=$(echo "$workflow" | awk '{print $1}')
workflow_user=$(echo "$workflow" | awk '{print $2}')
if ! kubectl get awsnodetemplate workflow-$workflow_name >/dev/null 2>&1; then
echo "No awsnodetemplate found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$AWSNODETEMPLATE_TEMPLATE" | kubectl apply -f -
fi
if [ ! -z "$workflow_name" ]; then
if ! kubectl get awsnodetemplate workflow-$workflow_name >/dev/null 2>&1; then
echo "No awsnodetemplate found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$AWSNODETEMPLATE_TEMPLATE" | kubectl apply -f -
fi
if ! kubectl get provisioner workflow-$workflow_name >/dev/null 2>&1; then
echo "No provisioner found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$PROVISIONER_TEMPLATE" | kubectl apply -f -
if ! kubectl get provisioner workflow-$workflow_name >/dev/null 2>&1; then
echo "No provisioner found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$PROVISIONER_TEMPLATE" | kubectl apply -f -
fi
fi
done
restartPolicy: OnFailure

0 comments on commit a9d20e9

Please sign in to comment.