Skip to content

Instantly share code, notes, and snippets.

@riskiwah
Created December 28, 2023 18:35
Show Gist options
  • Save riskiwah/55dca6297ea1efbff9aaaeea85d50385 to your computer and use it in GitHub Desktop.
Save riskiwah/55dca6297ea1efbff9aaaeea85d50385 to your computer and use it in GitHub Desktop.
quick cronjob kubernetes
apiVersion: batch/v1
kind: CronJob
metadata:
name: error-demo-cronjob
spec:
schedule: "*/5 * * * *"
successfulJobsHistoryLimit: 2
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: error-demo-container
image: busybox
command: ["false"] # This command always returns an error status
restartPolicy: OnFailure
apiVersion: batch/v1
kind: CronJob
metadata:
name: success-demo-cronjob
spec:
schedule: "*/1 * * * *"
successfulJobsHistoryLimit: 2
failedJobsHistoryLimit: 2
jobTemplate:
spec:
template:
spec:
containers:
- name: success-demo-container
image: busybox
command: ["/bin/sh", "-c"]
args:
- "sleep 5 && echo Hello"
restartPolicy: OnFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment