Jobs are the right workload for migrations, reports, calculations, and one-time administrative tasks.
Interactive guide to run-to-completion workloads, retries, completions, and parallel batch execution in Kubernetes.
A Job is about successful completion, not continuous availability. That changes how Kubernetes measures success, handles retries, and cleans up Pods.
k8s/labs/workloads/jobs.yaml — Job manifest demonstrating run-to-completion work with Pod template and completion settings.Jobs are the right workload for migrations, reports, calculations, and one-time administrative tasks.
A failed Pod can be retried until backoffLimit is reached.
Jobs can run one Pod or many Pods in parallel depending on the task.
The Job declares a Pod template plus success and retry settings.
The Job controller creates Pods to execute the batch task.
Completed Pods count toward the desired number of successful completions.
Failed runs may be retried depending on restartPolicy and backoffLimit.
The Job reaches a completed or failed state once its criteria are met.
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
kubectl get jobs
kubectl describe job pi
kubectl get pods -l job-name=pi
kubectl logs -l job-name=pi
| Feature | Job | Deployment |
|---|---|---|
| Purpose | Run to completion | Keep application running |
| Lifecycle | Ends when work finishes | Runs indefinitely |
| Success criteria | Completion count reached | Desired replicas remain available |
| Restart policy | Never or OnFailure | Controller keeps Pods replaced continuously |
Run schema changes before or during rollout in a controlled way.
Generate output files, analytics, or long-running calculations without long-lived Pods.
Backups, repair tasks, and one-time system operations fit naturally into Jobs.