| schedule | 五段 cron:分 时 日 月 周(如 0 2 * * *) |
|---|---|
| timeZone | 1.27 GA:timeZone: Asia/Shanghai 显式声明 |
| concurrencyPolicy | Allow(默认)/ Forbid / Replace |
| 历史保留 | successfulJobsHistoryLimit、failedJobsHistoryLimit |
| 补跑 | startingDeadlineSeconds 错过窗口内的补执行判断 |
CronJob 示例
CronJob 示例
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-backup
spec:
schedule: "0 2 * * *"
timeZone: Asia/Shanghai
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: backup
image: registry.example.com/team/backup:1.0.0
cron 表达式按 UTC 计算时,0 2 * * * 实际是北京时间 10 点:定时任务『跑偏』先查时区。