Completed pods garbage collection

10/10/2016

In The Lifecycle of a Pod I read:

In general, pods which are created do not disappear until someone destroys them. This might be a human or a ReplicationController, or another controller. The only exception to this rule is that pods with a PodPhase of Succeeded or Failed for more than some duration (determined by the master) will expire and be automatically reaped.

I create pods with RestartPolicy = Never, but after completion (status Succeeded) they do not get reaped.

Please advice.

-- yuval
kubernetes

1 Answer

10/10/2016

you can set --terminated-pod-gc-threshold on the controller-manager. That will kick in for phases:

if phase := pod.Status.Phase; phase != api.PodPending && phase != api.PodRunning && phase != api.PodUnknown

https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/podgc/gc_controller.go#L126

-- Prashanth B
Source: StackOverflow