------------- Minute (0 - 59)
| ----------- Hour (0 - 23)
| | --------- Day of month (1 - 31)
| | | ------- Month (1 - 12)
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | | |
- - - - -
* * * * * command to be executed
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: my-cron-job
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
completions: 3
parallelism: 3
template:
spec:
container:
- name: reporting-job
image: reporting-job-image
restartPolicy: Never
Notice there are 3
spec
sections in the job definition: One for the schedule, one for the job template and one for the actual container.
kubectl create -f cron-job-definition.yaml
kubectl get cronjob
NAME SCHEDULE SUSPEND ACTIVE
my-cron-job */1 * * * * False 0
kubectl create cronjob nginx --image=nginx --schedule="* * * * *" #cronJob