Jobs garbage collector¶
Build jobs and similar short-lived work leave Kubernetes objects behind. The garbage collector's policy decides whether those are kept, expired after their evidence is secured, or removed once it is. Evidence comes first in every mode.
Three retention modes¶
| Mode | Means |
|---|---|
retain |
The job object is kept |
ttl_after_evidence |
It expires a set time after evidence is secured |
delete_after_evidence |
It is removed once evidence is secured |
The default time to live is 600 seconds, so ttl_after_evidence leaves a ten
minute window by default.
Evidence before cleanup, in every mode¶
flowchart TB
A["Job completes"]
B["Evidence secured"]
C["retain: kept"]
D["ttl_after_evidence: expires after the TTL"]
E["delete_after_evidence: removed"]
A --> B
B --> C
B --> D
B --> E
Where the policy is held and applied¶
flowchart LR
subgraph CP["CONTROL PLANE"]
direction TB
GP[("Jobs GC policy<br/>mode, TTL")]
end
subgraph YI["YOUR CLUSTER"]
direction TB
N["xratud<br/>GC runtime"]
JO[("Job objects")]
EV{{"Evidence secured?"}}
N --> EV
EV -->|"yes"| JO
end
GP -->|"policy"| N
The policy is a control-plane record, and it is applied by the node inside your cluster, where the job objects are. The evidence check sits between the node and the objects, so no mode reaches an object whose evidence is not yet secured.
Two of the three modes are named for the condition rather than for a timer. Cleanup is gated on evidence being secured, so a job object is never removed while it is still the only place something is recorded.
Choosing a mode¶
retain is the debugging posture: job objects accumulate and can be inspected
long after the fact, at the cost of cluster objects.
ttl_after_evidence is the usual choice. Evidence is secured, a window remains
for inspection, and the object goes.
delete_after_evidence is the tightest. It suits deployments where cluster
object count matters and where the recorded evidence is accepted as sufficient.
The policy is resolved, not configured per job¶
One operation exists: resolving the policy. A job does not carry its own retention choice; the policy in force is resolved and applied, so cleanup behaviour is uniform and answerable from one place.
The collector runs in the controller loop¶
Garbage collection of terminal runs is part of the controller manager's fixed order, after convergence work and before the outbox flush. It is bounded like every other controller, so cleanup proceeds over cycles rather than in one sweep. See The controller manager.
What it does not decide¶
The garbage collector's policy covers job objects. How long the control plane keeps the metadata, lineage and evidence references those jobs produced is retention's question, and retention is a governance authority with legal hold over it. See Retention authority.
Keeping the two separate means cleaning up cluster objects can be aggressive without touching what an audit depends on.