---
source: https://iinventedlight.com/library/notes/kubernetes-jobs.md
title: "Kubernetes Jobs"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (kubernetes/website); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Kubernetes Authors, Jobs, CC BY 4.0 (kubernetes/website); Kubernetes Authors, Automatic Cleanup for Finished Jobs, CC BY 4.0 (kubernetes/website)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Kubernetes"
tags: ['kubernetes', 'jobs', 'batch', 'workloads']
sources:
  - id: S1
    title: "Jobs"
    publisher: Kubernetes Authors
    url: https://kubernetes.io/docs/concepts/workloads/controllers/job/
    accessed: 2026-11-04
    license: "CC BY 4.0 (kubernetes/website)"
  - id: S2
    title: "Automatic Cleanup for Finished Jobs"
    publisher: Kubernetes Authors
    url: https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/
    accessed: 2026-11-04
    license: "CC BY 4.0 (kubernetes/website)"
---
# Kubernetes Jobs

**Answer:** A Kubernetes Job runs Pods to completion. It creates one or more Pods and keeps retrying until a set number finish successfully; then the Job is complete.

## Example

```yaml
apiVersion: batch/v1
kind: Job
metadata: {name: pi}
spec:
  completions: 1
  parallelism: 1
  backoffLimit: 4
  ttlSecondsAfterFinished: 100
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: pi
        image: perl
        command: ["perl","-Mbignum=bpi","-wle","print bpi(2000)"]
```

## Key fields

- **completions:** how many successful Pods are needed.
- **parallelism:** how many run at once.
- **backoffLimit:** retries before the Job is marked failed.
- **ttlSecondsAfterFinished:** delete the finished Job (and its Pods) after this many seconds.

## Inspecting

```bash
kubectl get pods --selector=batch.kubernetes.io/job-name=pi
kubectl logs job/pi
```

Deleting a Job also deletes the Pods it created.

## Claims
- id: C1
  claim: A Job retries Pods until a specified number successfully terminate.
  source: S1
  evidence: "A Job creates one or more Pods and will continue to retry execution of the"
- id: C2
  claim: When enough completions are reached, the Job is complete.
  source: S1
  evidence: "of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will"
- id: C3
  claim: Cleanup uses the ttlSecondsAfterFinished field of a Job.
  source: S2
  evidence: ".spec.ttlSecondsAfterFinished field of a Job, as in this"
- id: C4
  claim: The TTL-after-finished controller is only supported for Jobs.
  source: S2
  evidence: "The TTL-after-finished controller is only supported for Jobs."

## Sources
- [S1] Jobs. Kubernetes Authors. https://kubernetes.io/docs/concepts/workloads/controllers/job/ . License: CC BY 4.0 (kubernetes/website). Accessed 2026-11-04.
- [S2] Automatic Cleanup for Finished Jobs. Kubernetes Authors. https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/ . License: CC BY 4.0 (kubernetes/website). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
