Skip to main content

More Info:

Verifies that the controller manager —terminated-pod-gc-threshold argument is set so terminated pods are garbage collected, preventing resource exhaustion.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. Back up the existing manifest (every control plane node)
  2. Open the controller manager manifest for editing (every control plane node)
    (Use any text editor you prefer.)
  3. Set --terminated-pod-gc-threshold in the container args (every control plane node)
    In the spec.containers[0].command or spec.containers[0].args list for kube-controller-manager, ensure there is an entry like the following (adjust the value as appropriate for your cluster policy, e.g. 10):
    Save and exit the editor.
    Note: Editing this static pod manifest under /etc/kubernetes/manifests will cause the kube-controller-manager pod to be restarted automatically by the kubelet.
  4. Wait for the kube-controller-manager pod to restart cleanly (every control plane node)
    From any machine with kubectl and access to the cluster:
    Wait until the pod is back in Running status and no longer restarting.
  5. Verify the running process includes the flag (every control plane node)
    Confirm the output shows --terminated-pod-gc-threshold=10 (or the value you configured) in the kube-controller-manager process arguments.
kubectl cannot modify the kube-controller-manager arguments because they are defined in the static pod manifest /etc/kubernetes/manifests/kube-controller-manager.yaml on each control plane node. To set --terminated-pod-gc-threshold, follow the instructions in the Manual Steps section on each control plane node.