Skip to content

Instantly share code, notes, and snippets.

@knil-sama
Last active September 2, 2019 20:50
Show Gist options
  • Save knil-sama/1fb0e7aa49469e4ab28b4b88d7ed1eec to your computer and use it in GitHub Desktop.
Save knil-sama/1fb0e7aa49469e4ab28b4b88d7ed1eec to your computer and use it in GitHub Desktop.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: example
namespace: default
spec:
schedule: '*/1 * * * *'
jobTemplate:
spec:
template:
spec:
initContainers:
- name: wait-for-service
image: busybox
command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done']
- name: wait-for-db
image: postgres
command: ['pg_isready', '-h', 'someremotehost']
- name: clean-up-db
image: busybox
command: ['sh', '-c', 'psql -f clean_up.psql']
containers:
- name: fake-job
image: own-image
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
restartPolicy: OnFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment