Created
November 8, 2021 06:22
-
-
Save bluebrown/635e8c35de04e2d4dba3088f5e895975 to your computer and use it in GitHub Desktop.
use kubectl init container to wait for job to complete before unblocking the actual pod
This file contains 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: myjob | |
spec: | |
ttlSecondsAfterFinished: 10 | |
template: | |
spec: | |
containers: | |
- name: sleeper | |
image: busybox | |
command: ["sleep", "30"] | |
restartPolicy: Never | |
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: myapp | |
labels: | |
name: myapp | |
spec: | |
initContainers: | |
- name: wait-for-job | |
image: bitnami/kubectl | |
args: | |
- wait | |
- job.batch/myjob | |
- --for | |
- condition=complete | |
- --timeout | |
- 60s | |
containers: | |
- name: myapp | |
image: nginx | |
ports: | |
- containerPort: 80 | |
resources: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment