☑️ Ensure CronJob has a configured deadline
When the CronJob controller counts more than 100 missed schedules, the cron job is no longer scheduled. Missed CronJobs are considered failures.
By default, the CronJob controller counts how many missed schedules happen for a cron job since status.lastScheduleTime
until now. When startingDeadlineSeconds
is set, the CronJob controller counts how many missed jobs occurred between the value of startingDeadlineSeconds
until now.
Setting a deadline can reduce the number of missed schedules needed to mark a CronJob as a failure while increasing the CronJob reliability.
Targeted objects by this rule (types of kind
): CronJob
Complexity: medium (What does this mean?)
Policy as code identifier: CRONJOB_MISSING_STARTINGDEADLINESECOND_KEY
This rule will fail
If a CronJob doesn't have a startingDeadlineSeconds
key configured
kind: CronJob
spec:
schedule: "*/1 * * * *"
Rule output in the CLI
$ datree test *.yaml
>> File: failExample.yaml
❌ Ensure CronJob has a configured deadline [1 occurrence]
💡 Missing property object `startingDeadlineSeconds` - set a time limit for the cron execution to allow killing it if exceeded
How to fix this failure
kind: CronJob
spec:
schedule: "*/1 * * * *"
startingDeadlineSeconds: 100