Pcornel
Containers · Kubernetes Workloads

Jobs and CronJobs

Cheat sheet · https://pcornel.dk/topic.php?topic=6147

Back to the Topic

Answer

Jobs run pods to completion with retries (backoffLimit); CronJobs create Jobs on a cron schedule.

Remember

Check concurrencyPolicy, startingDeadlineSeconds and history limits. Failed pods keep logs only while retained. The CronJob schedule uses the controller's time zone unless timeZone is set.

First checks

  • kubectl get cronjob,job -n <ns> — first check for this topic
  • kubectl get pods -o wide — pods, status, node, IP
  • kubectl describe pod <pod> — events and conditions
  • kubectl logs <pod> [-c <c>] [--previous] — container logs (incl. previous crash)
  • kubectl get events --sort-by=.lastTimestamp — recent cluster events

Commands

kubectl get cronjob,job
kubectl create job --from=cronjob/db-backup manual-1

Verify in this order

CronJob schedule → Job → pod runs to completion → success/fail recorded

Where it usually breaks

restartPolicy Always is not allowed in a Job.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6147

Confirmation

Confirm action

Continue?