|
| 1 | +# |
| 2 | +# This job is responsible for triggering the .werft/platform-clean-up-werft-build-node.yaml job |
| 3 | +# for each node that has the dev/workload label set to "builds" |
| 4 | +# |
| 5 | +# It is a Werft cron job that runs periodically but you can always manually trigger it using |
| 6 | +# |
| 7 | +# werft job run github -j .werft/platform-trigger-werft-cleanup.yaml |
| 8 | +# |
| 9 | +pod: |
| 10 | + serviceAccount: werft |
| 11 | + affinity: |
| 12 | + nodeAffinity: |
| 13 | + requiredDuringSchedulingIgnoredDuringExecution: |
| 14 | + nodeSelectorTerms: |
| 15 | + - matchExpressions: |
| 16 | + - key: dev/workload |
| 17 | + operator: In |
| 18 | + values: |
| 19 | + - "builds" |
| 20 | + volumes: |
| 21 | + # Needed to install the core-dev kubectl context to talk to Werft |
| 22 | + - name: gcp-sa |
| 23 | + secret: |
| 24 | + secretName: gcp-sa-gitpod-dev-deployer |
| 25 | + containers: |
| 26 | + - name: build |
| 27 | + image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:cw-werft-cred.0 |
| 28 | + workingDir: /workspace |
| 29 | + imagePullPolicy: IfNotPresent |
| 30 | + env: |
| 31 | + - name: WERFT_K8S_NAMESPACE |
| 32 | + value: werft |
| 33 | + - name: WERFT_DIAL_MODE |
| 34 | + value: kubernetes |
| 35 | + - name: WERFT_CREDENTIAL_HELPER |
| 36 | + value: "" |
| 37 | + volumeMounts: |
| 38 | + - name: gcp-sa |
| 39 | + mountPath: /mnt/secrets/gcp-sa |
| 40 | + readOnly: true |
| 41 | + command: |
| 42 | + - bash |
| 43 | + - -c |
| 44 | + - | |
| 45 | + sleep 1 |
| 46 | + set -Eeuo pipefail |
| 47 | +
|
| 48 | + # This is needed to run Werft jobs from Github |
| 49 | + sudo chown -R gitpod:gitpod /workspace |
| 50 | + git config --global user.name roboquat |
| 51 | + git config --global user.email roboquat@gitpod.io |
| 52 | +
|
| 53 | + # Install core-dev context |
| 54 | + gcloud auth activate-service-account --key-file "/mnt/secrets/gcp-sa/service-account.json" |
| 55 | + gcloud container clusters get-credentials core-dev --zone europe-west1-b --project gitpod-core-dev |
| 56 | +
|
| 57 | + echo "[Triggering clean up jobs|PHASE] Triggering the cleanup job for each node" |
| 58 | +
|
| 59 | + nodes=$(kubectl get nodes -l dev/workload=builds --no-headers -o custom-columns=":metadata.name") |
| 60 | +
|
| 61 | + for node in $nodes ; do |
| 62 | + echo "[Cleanup up node $node] Triggering the cleanup job for $node" |
| 63 | + werft job run github -j .werft/platform-clean-up-werft-build-node.yaml -a node="$node" \ |
| 64 | + | werft log slice "Cleanup up node $node" |
| 65 | + echo "[Cleanup up node $node|DONE]" |
| 66 | + done |
| 67 | +plugins: |
| 68 | + cron: "@midnight" |
0 commit comments