Last active
October 3, 2017 02:49
-
-
Save dimroc/15fee5635345bc2b8acd9ef00410cb17 to your computer and use it in GitHub Desktop.
Kubernetes rake <arbitrary tasks> job runner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } | |
| template=`cat ./jobs/rake.yaml` | |
| joined=$(join_by \",\" $@) | |
| args=[\"$joined\"] | |
| job="${template//"\$\$RAKECMD"/$args}" | |
| echo "$job" | kubectl create -f - | |
| kubectl get pods -a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: batch/v1 | |
| kind: Job | |
| metadata: | |
| name: rake | |
| spec: | |
| template: | |
| metadata: | |
| name: rake | |
| spec: | |
| restartPolicy: Never | |
| containers: | |
| - name: rails | |
| image: us.gcr.io/counting-company-production/rails | |
| envFrom: | |
| - secretRef: | |
| name: rails-environment | |
| volumeMounts: | |
| - name: cloudstorage-instance-credentials | |
| mountPath: /secrets | |
| readOnly: true | |
| command: ["rake"] | |
| args: $$RAKECMD | |
| volumes: | |
| - name: cloudstorage-instance-credentials | |
| secret: | |
| secretName: cloudstorage-instance-credentials |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
output
Used fancy bash join found here: https://stackoverflow.com/questions/1527049/join-elements-of-an-array