← All notes

Kubernetes ttlSecondsAfterFinished - automatically delete finished Jobs and their Pods

Answer: To clean up finished Jobs automatically, specify the ttlSecondsAfterFinished field of a Job. Once the TTL has expired, the Job is removed along with its dependent objects.

Example

apiVersion: batch/v1
kind: Job
metadata:
  name: pi-with-ttl
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
      - name: pi
        image: perl:5.34.0
        command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
kubectl patch job old-job --type=merge -p '{"spec":{"ttlSecondsAfterFinished":0}}'

How it works

Ways to set it

Caveats

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Automatic Cleanup for Finished Jobs; kubernetes/website (GitHub), ttlafterfinished.md (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Automatic Cleanup for Finished Jobs; kubernetes/website (GitHub), ttlafterfinished.md (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.

Cite this

Permanent ID: iil:note:pm9zerxm

iinventedlight. 2026. "Kubernetes ttlSecondsAfterFinished - automatically delete finished Jobs and their Pods." iinventedlight Library, iil:note:pm9zerxm, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-ttl-after-finished/. License: CC-BY-4.0.

@misc{iil_note_pm9zerxm,
  author = {{iinventedlight}},
  title = {{Kubernetes ttlSecondsAfterFinished - automatically delete finished Jobs and their Pods}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/kubernetes-ttl-after-finished/},
  note = {Permanent ID iil:note:pm9zerxm. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-ttl-after-finished.md.