Hand finite work to a Job The user submits a Job that builds the monthly report. A Job is a one-off run that ends once its work is done.
This Job says "done after one success (completions: 1)" and "retry up to 3 times on failure (backoffLimit: 3)".
The Job creates a Pod to do the work The Job does not do the work itself. It creates a Pod, gives it the work, and watches how the Pod ends.
A Job’s Pod has restartPolicy Never or OnFailure. That is what sets it apart from a Deployment’s Pod, which must stay up.
If the Pod fails, a new Pod retries pod-1 exited with an error. The Job detects the failure and creates pod-2 to do the same work again.
The wait before each retry grows a little longer. The failed pod-1 is not deleted, so you can still read its logs.
Watch out Once failures exceed backoffLimit, the Job stops retrying and ends as Failed. If unset, the default is 6.
When the Pod exits cleanly, the Job completes pod-2 finished its work and exited cleanly. The success count reached completions (1), so the Job becomes Complete.
The finished Pod stays as Completed. It does not restart and uses no more resources.
Key idea A Deployment aims to "keep running"; a Job aims to "finish successfully". For a Job, exiting is normal.
A CronJob stamps out a Job on each schedule A CronJob holds a schedule as a cron expression such as "0 2 * * *". Every day at 02:00 it creates a new Job.
The CronJob itself does no work. The Job it creates makes a Pod and watches it to completion, exactly as before.
The next run is due before the last one finished With lots of data, the 02:00 run is still going at 02:00 the next day. What happens now is set by concurrencyPolicy.
Allow (the default) creates another Job to run alongside, Forbid skips this run, and Replace deletes the running Job and starts a new one.
Watch out Two runs editing the same data at once can corrupt the result. If runs must not overlap, choose Forbid or Replace.
Finished Jobs are kept only up to a limit A long-lived CronJob would pile up Jobs on every run. So by default it keeps 3 successful and 1 failed Job and deletes the oldest first.
For Jobs you create yourself, set ttlSecondsAfterFinished and the Job is deleted with its Pods that long after finishing. Otherwise it stays until you delete it.
Key idea Deleting history also removes that Job’s Pods and logs. If you need the cause of a failure, look before it is cleaned up.
A workload where finishing is normal A Job creates Pods, watches them to completion, and retries up to backoffLimit on failure. A CronJob creates such a Job on every schedule.
Logs live in the Pods the Job created, not in the Job itself. Read them with kubectl logs job/NAME or by Pod name.
Summary A Job watches to completion and retries on failure; a CronJob creates Jobs on a schedule. To confirm a schedule actually ran, check LAST SCHEDULE in kubectl get cronjob and the Job’s COMPLETIONS.