CronJobs: Automated Scheduled Tasks
A CronJob creates Jobs on a repeating schedule using standard crontab expressions.
1. CronJob Manifest Example
Section titled “1. CronJob Manifest Example”apiVersion: batch/v1kind: CronJobmetadata: name: nightly-database-backupspec: schedule: "0 2 * * *" # Every day at 02:00 AM UTC concurrencyPolicy: Forbid successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 1 jobTemplate: spec: template: spec: restartPolicy: OnFailure containers: - name: db-backup image: postgres:15-alpine command: ["/bin/sh", "-c", "pg_dumpall -h db.prod > /backups/dump.sql"]Concurrency Policies
Section titled “Concurrency Policies”Allow(default): Concurrent jobs are allowed to run concurrently.Forbid: If a previous job is still running, the new scheduled run is skipped.Replace: Cancels the currently running job and starts a new one.