https://kubernetes.io/zh/docs/concepts/workloads/controllers/cron-jobs/ https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ jobs: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#writing-a-job-spec
cron job -> (0-2)job -> pod One CronJob Object similar to crontab （cron table） A line in a document . It periodically runs a Job Cron Job During each scheduling run time Probably Will create a Job object . The reason why we say Probably , It's because in a particular environment, you might create two Job, Or a Job None of them were created . We're trying to reduce that , But it can't be completely avoided . therefore , establish Job The operation should be _ idempotent _. Job Based on what it creates Pod Parallelism of , Responsible for creating Pod, And decided on this group Pod Success or failure of . Cron Job I'm not going to check at all Pod -- see cronjob kubectl get cronjob -n niuniu kubectl get cronjob -n niuniu --watch --- apiVersion: batch/v1beta1 kind: CronJob metadata: namespace: niuniu name: autocheckout labels: app: cron spec: schedule: "*/1 * * * *" concurrencyPolicy: Allow startingDeadlineSeconds: 300 successfulJobsHistoryLimit: 1 failedJobsHistoryLimit: 1 jobTemplate: .spec.startingDeadlineSeconds Fields are optional . It means start Job Time limit of （ Second level ）, If the scheduled time is missed for any reason , So what's missing execution time Job Will be considered a failure . If not specified , There is no deadline Concurrency strategy .spec.concurrencyPolicy Fields are also optional . It specifies how to deal with being Cron Job Created Job Concurrent execution of . Only one of the following policies is allowed to be specified ： Allow（ Default ）： Allow concurrent runs Job Forbid： Prohibit concurrent running , If the previous one hasn't been completed yet , Then skip the next one Replace： Cancel the currently running Job, Replace... With a new one Be careful , The current policy can only be applied to the same Cron Job Created Job. If there are multiple Cron Job, They were created Job Always allow concurrent runs between . Hang up .spec.suspend Fields are also optional . If set to true, All subsequent execution will be suspended . It's about what's already being done Job It doesn't work . The default value is false. Job Historical limitations .spec.successfulJobsHistoryLimit and .spec.failedJobsHistoryLimit They specify that completion and failure can be retained Job The limit of quantity . There are no restrictions by default , All the success and failure Job Will be preserved . However , When running a Cron Job when , It's going to pile up a lot soon Job, It is recommended to set the values of these two fields . Set the limit value to 0, Related types of Job It will not be retained after completion .