Controller Manager pod does not use the default --terminated-pod-gc-threshold value
Kubernetes controller manager terminated Pod garbage collection threshold is evaluated. The finding highlights use of the default --terminated-pod-gc-threshold=12500 instead of a value tuned to cluster size and workload churn. The threshold controls when terminated Pods are automatically removed.
Risk
Retaining too many terminated Pods strains API server, etcd, and controller memory, reducing control-plane availability. Effects include slow list/watch operations, lagging schedulers, timeouts, and, in worst cases, controller crashes or admin-plane DoS.
Run this check with Prowler
Run in Prowler Cloudprowler kubernetes --checks controllermanager_garbage_collectionRecommendation
Set a lower, context-appropriate --terminated-pod-gc-threshold to match cluster scale and pod churn, preserving control-plane capacity. Monitor garbage collection and control-plane metrics and adjust proactively. Use ttlSecondsAfterFinished for Jobs to minimize terminated Pods.
Remediation
Other
Check Code
from prowler.lib.check.models import Check, Check_Report_Kubernetes
from prowler.providers.kubernetes.services.controllermanager.controllermanager_client import (
controllermanager_client,
)
class controllermanager_garbage_collection(Check):
def execute(self) -> Check_Report_Kubernetes:
findings = []
for pod in controllermanager_client.controllermanager_pods:
report = Check_Report_Kubernetes(metadata=self.metadata(), resource=pod)
report.status = "PASS"
report.status_extended = f"Controller Manager has an appropriate garbage collection threshold in pod {pod.name}."
for container in pod.containers.values():
if "--terminated-pod-gc-threshold=12500" in str(container.command):
report.status = "FAIL"
report.status_extended = f"Controller Manager has the default garbage collection threshold in pod {pod.name}."
findings.append(report)
return findings