- .spec.schedule 指定任务运行周期,格式同 Cron
- .spec.jobTemplate 指定需要运行的任务,格式同 Job
- .spec.startingDeadlineSeconds 指定任务开始的截止期限
- .spec.concurrencyPolicy 指定任务的并发策略,支持 Allow、Forbid 和
Replace - 三个选项
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date;echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
查看日志
//查看job和查看cronjob
kubect get job
kubect get cronjob
pods=$(kubectl get pods --selector=job-name=hello-27280025 --output=jsonpath={.items..metadata.name} )
kubectl logs $pods