Use this when running one-off tasks to completion in Kubernetes, such as migrations.
Jobs · Kubernetes Automation
Kubernetes Jobs run pods until a task completes successfully, such as a database migration, with retries via backoffLimit and parallelism settings.
1. Jobs run to completion.
2. Set backoffLimit and deadlines.
3. TTL to clean up.
4. Idempotent workloads.
5. Logs for results.
Job → pods → completion
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Effective-state and workload closure Verify boundary
Follow one job ID through queue and worker, verify exactly-once/idempotent target outcome, read effective state and run the original workload after terminal completion.
Step 2 Example Narrow the fault
kubectl create job backup-now --from=cronjob/backup
kubectl logs job/backup-now
Step 3 Common mistakes Narrow the fault
- No
ttlSecondsAfterFinished, leaving old jobs around.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- A Job runs pods until they succeed.
- backoffLimit controls retries.
- Clean up finished Jobs with ttlSecondsAfterFinished.
kubectl get jobs -n <ns>— jobskubectl logs job/<n>— output- backoffLimit/activeDeadlineSeconds/ttlSecondsAfterFinished — limits
ReferenceWhy it matters1 section · depth on demand
What it is
A Job runs pods to completion, with retries (backoffLimit) and parallelism.
ReferenceImportant terms & boundaries2 sections · depth on demand
Mechanics
The linked authority for bounded mechanics is Kubernetes Documentation; documentation support is separate from observed lab/production Evidence.
In depth
A Job runs pods until a task completes successfully — a migration, a batch import, a one-off configuration push. Unlike a Deployment, which keeps pods running forever, a Job is finished when the specified number of pods have succeeded.
apiVersion: batch/v1
kind: Job
metadata: { name: import-prefixes }
spec:
backoffLimit: 3
activeDeadlineSeconds: 900
ttlSecondsAfterFinished: 3600
template:
spec:
restartPolicy: Never
containers:
- name: import
image: registry.example.com/ipam-tools:2.1
args: ["import", "/data/prefixes.csv"]
kubectl wait --for=condition=complete job/import-prefixes --timeout=15m
kubectl logs job/import-prefixes
backoffLimit caps retries; activeDeadlineSeconds caps total runtime; ttlSecondsAfterFinished cleans up finished Jobs.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Kubernetes Automation > Jobs. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://kubernetes.io/docs/home/ · confidence 94%