K8s by Example: Jobs & CronJobs
| Jobs run a task to completion. Unlike Deployments that run indefinitely, Jobs ensure a specified number of Pods successfully complete. Use for: migrations, batch processing, backups, one-time tasks. |
| job.yaml | |
| Job runs Pods until successful completion. | |
| job-parallel.yaml | |
| Job completion modes: | |
| job-lifecycle.yaml | |
|
| |
| job-modes.yaml | |
| Parallel Jobs have three modes. First example: fixed completion count (run 10 total, 3 at a time). Second example: work queue (no completions = Pods coordinate, done when any Pod exits 0). Third example: single Pod (default). | |
| cronjob.yaml | |
| CronJobs run Jobs on a schedule using cron syntax (minute hour day-of-month month day-of-week). Schedule examples in code. Use | |
| cronjob-policy.yaml | |
|
| |
| terminal | |
| Suspend and resume CronJobs. Trigger manual runs from existing CronJob template. View Job history and logs. | |
| terminal | |
| Debug Jobs by checking Pod status, logs, and completion status. Failed Jobs show backoff events. CronJobs show scheduled vs actual run times. | |