Description
startingDeadlineSeconds sets how late the CronJob controller may create a Job after its scheduled time. Omit it if delayed runs are acceptable. The controller can still skip missed runs.
Potential impact
A late Job can act on stale data. A deadline shorter than routine controller delays can skip work that should run.
Remediation
- Set
spec.startingDeadlineSecondsto the longest useful delay, allowing for the controller’s check interval and operational delays. - Make the Job safe to repeat and review
concurrencyPolicyand retries. To limit runtime after the Job starts, set the Job’sactiveDeadlineSeconds.
Examples
Provide the job command and a verified image version. Adjust the sample deadline to suit the job.
Before
yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
restartPolicy: OnFailure
With no start deadline, a missed run can start after the controller recovers.
After
yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
startingDeadlineSeconds: 100
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
restartPolicy: OnFailure
The controller has up to 100 seconds after the scheduled time to create this Job.