Skip to main content

More Info:

Verifies every container sets resources.limits.cpu and resources.limits.memory so a single workload cannot exhaust a node.

Risk Level

Medium

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. Identify noncompliant pods and their owning workloads (run on any machine with kubectl access):
  2. For each owning workload (e.g., Deployment, StatefulSet, DaemonSet, Job, CronJob) that has noncompliant containers, export its manifest (run on any machine with kubectl access, substitute actual values):
    (Replace deployment with the actual kind, e.g. statefulset, daemonset, job, cronjob as needed.)
  3. Edit the exported manifest to set CPU and memory limits on every container in the pod template (run on any machine with kubectl access, using your editor of choice, example with vi):
    Under each .spec.template.spec.containers[].resources, ensure you have both:
    If resources or limits is missing, add these sections. Set values according to your application requirements and node capacities.
  4. Apply the updated manifest back to the cluster (run on any machine with kubectl access):
    Repeat steps 2–4 for each noncompliant owning workload identified in step 1.
  5. For standalone Pods without a controller (no ownerKind/ownerName in step 1 output), recreate them with limits set:
    • Get the current pod spec:
    • Edit /tmp/pod-POD_NAME.yaml to add resources.limits.cpu and resources.limits.memory for every container as in step 3, and remove cluster-assigned fields (e.g. metadata.resourceVersion, metadata.uid, metadata.creationTimestamp, status block).
    • Delete and recreate the pod (run on any machine with kubectl access):
  6. Verify all non-excluded pods are now compliant (run on any machine with kubectl access):
On any machine with kubectl access:
  1. Identify non-compliant pods and their controllers
Focus on the owning controller kinds such as Deployment, StatefulSet, DaemonSet, Job, CronJob; editing those will fix their pods.
  1. Edit a workload to add limits (example for a Deployment)
Under each spec.template.spec.containers[], add both cpu and memory limits, for example:
Save and exit; Kubernetes will roll out updated pods.
  1. Apply limits via manifest (declarative)
If you manage manifests (e.g., Git, Helm, Kustomize), edit the YAML for each controller and add the same resources block under each container, then apply:
Repeat for all controllers that create non-compliant pods.
  1. For standalone Pods (no controller)
For pods whose owner kind is Pod (no higher-level controller), you must recreate them because pod specs are immutable:
Edit /tmp/your-pod.yaml:
  • Remove fields under metadata such as uid, resourceVersion, creationTimestamp, managedFields, selfLink, generation.
  • Remove status completely.
  • Under each spec.containers[], add:
Then delete and recreate:
  1. Verification
Run the benchmark audit command again from any machine with kubectl access:
Non-compliant containers will show limitsCpu=unset or limitsMemory=unset; adjust remaining workloads until all are compliant.