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 (run on any machine with kubectl access):
  2. Choose a noncompliant workload and fetch its manifest (any machine with kubectl access). Example for a pod in namespace default named myapp-pod:
  3. Edit the manifest to add CPU and memory limits for each container (any machine with kubectl access). Open the file:
    Under each .spec.containers[].resources section, ensure something like:
    Adjust values per your capacity and application requirements.
  4. Recreate the pod with the updated manifest (any machine with kubectl access). Pods created by higher-level controllers (Deployments, StatefulSets, etc.) should be fixed at the controller level instead; for a standalone pod:
  5. For pods managed by controllers (recommended in EKS), patch the controller instead of individual pods (any machine with kubectl access). Example for a Deployment myapp-deploy in default namespace:
    In the editor, under spec.template.spec.containers[], add:
    Save and exit so the Deployment rolls out updated pods.
  6. Verify all non-system pods now have CPU and memory limits (any machine with kubectl access):
    Ensure the output is is_compliant=true.
On any machine with kubectl access:
  1. Identify non‑compliant Pods and their controllers
For each line, note ownerKind and ownerName. Always patch the controller (Deployment/StatefulSet/DaemonSet/Job/CronJob), not the Pod, so the setting persists.
  1. Example: patch a Deployment’s containers to add limits
Edit the Deployment manifest:
In /tmp/deploy.yaml, under each .spec.template.spec.containers[].resources, add:
(adjust values to your policy; repeat for every container.)Apply the updated manifest:
  1. Example: patch a single container in place (quick fix)
Adjust the container index in the path and the limit values as needed.Use the same approach (kubectl get ... -o yaml → edit → kubectl apply) for StatefulSets, DaemonSets, Jobs, and CronJobs.
  1. For standalone Pods (no ownerReference)
Export, edit, and re‑create with a controller (recommended) or as a Pod:
Edit /tmp/pod.yaml: remove fields under status:, remove metadata.uid, metadata.resourceVersion, metadata.creationTimestamp, and set resources.limits as above for each container. Then:
  1. Verification
Re‑run the benchmark audit command from any machine with kubectl access:
All reported containers should now show non‑unset limitsCpu and limitsMemory and is_compliant=true.