Review terminated Pod cleanup thresholds

Choose cleanup thresholds that balance terminated Pod retention with control-plane resource use.

Description

--terminated-pod-gc-threshold sets the cluster-wide count of terminated Pods above which the controller starts cleanup. A value of 0 or less disables this count-based cleanup.

Potential impact

Accumulated objects can increase control-plane load. Removing them too soon can discard Pod information needed for investigation.

Remediation

Choose a positive value based on Pod turnover and investigation needs. The current default is 12500. Set log and audit retention separately, then check that the evidence you need remains after Pod objects are deleted.

Examples

The Kubernetes 1.6.0 controller-manager excerpts change 0 to 10. With this setting, count-based cleanup starts above ten terminated Pods. Choose a threshold for your cluster on a supported version.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
spec:
  containers:
    - name: command-demo-container
      image: gcr.io/google_containers/kube-controller-manager-amd64:v1.6.0
      command: ["kube-controller-manager", "--terminated-pod-gc-threshold=0"]
      args: []

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
spec:
  containers:
    - name: command-demo-container
      image: gcr.io/google_containers/kube-controller-manager-amd64:v1.6.0
      command: ["kube-controller-manager"]
      args: ["--terminated-pod-gc-threshold=10"]

References