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 controllers (run on any machine with kubectl access):
  2. For a pod managed by a controller (e.g., Deployment), edit the controller manifest to add limits (run on any machine with kubectl access):
    In each container under spec.template.spec.containers, ensure:
    Adjust values to match your capacity and SLOs, then save and exit to let Kubernetes roll out updated pods.
  3. For other controllers (StatefulSet, DaemonSet, Job, CronJob), edit similarly (run on any machine with kubectl access):
    Add or update resources.limits.cpu and resources.limits.memory for every container in spec.template.spec.containers (or spec.jobTemplate.spec.template.spec.containers for CronJob).
  4. For standalone pods without controllers that must be kept, export, modify, and recreate (run on any machine with kubectl access):
    Edit /tmp/pod-with-limits.yaml:
    • Remove fields status, metadata.resourceVersion, metadata.uid, metadata.creationTimestamp, and metadata.ownerReferences.
    • Under every container in spec.containers, add:
    Then recreate:
  5. Optionally enforce future compliance with a LimitRange in each namespace (run on any machine with kubectl access):
  6. Verify all non-system pods now have CPU and memory limits (run on any machine with kubectl access):
On any machine with kubectl access:
  1. Identify non‑compliant pods and their owning controllers
This outputs lines like: Deployment default my-app
  1. Patch a controller to add limits (example for a Deployment)
Export the manifest, edit, and re-apply:
Edit /tmp/my-app-deploy.yaml and, for each container under spec.template.spec.containers, ensure a resources block like:
Apply the updated manifest:
Repeat this export/edit/apply pattern for each non‑compliant controller kind (e.g., StatefulSet, DaemonSet, Job, CronJob, ReplicaSet if managed directly), always updating the containers in spec.template.spec.containers.
  1. For bare Pods (no ownerReferences)
Export, edit, and re‑create:
In /tmp/my-pod.yaml:
  • Remove the entire status: section.
  • Under spec.containers[], add resources.limits.cpu and resources.limits.memory as above.
Delete and recreate:
  1. Verification
On any machine with kubectl access: