Skip to content

Instantly share code, notes, and snippets.

@bluebrown
Created November 8, 2021 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluebrown/635e8c35de04e2d4dba3088f5e895975 to your computer and use it in GitHub Desktop.
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
---
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