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. List non-compliant pods (run on any machine with kubectl access):
  2. Choose one non-compliant pod and check if it is controlled by a higher-level object (run on any machine with kubectl access):
    • If empty: fix the Pod manifest directly (step 3).
    • If it has an owner (e.g., Deployment, StatefulSet, Job, CronJob, ReplicaSet, DaemonSet): fix that owner resource (step 4); do not edit the pod directly.
  3. For a standalone Pod: export its manifest, edit, and re-apply (run on any machine with kubectl access):
    Edit /tmp/pod-POD_NAME.yaml and under each .spec.containers[].resources ensure:
    Then delete the running pod and recreate it from the edited manifest:
  4. For controller-managed pods: edit the controller so all its containers set limits (run on any machine with kubectl access). Example for a Deployment:
    In the editor, for each container under spec.template.spec.containers[], ensure:
    Save and exit. Kubernetes will roll out updated pods automatically.
    Use the equivalent kubectl edit statefulset, kubectl edit daemonset, kubectl edit job, or kubectl edit cronjob for other controllers.
  5. (Optional but recommended) Enforce limits via a LimitRange in each namespace so new pods must set them (run on any machine with kubectl access):
  6. Verify all non-exempt pods and containers now have CPU and memory limits (run on any machine with kubectl access):
    The output should be is_compliant=true.
On any machine with kubectl access:
  1. Identify pods/containers missing limits (example, focused view):
  1. For each affected pod, edit the owning workload manifest to add resources.limits.cpu and resources.limits.memory for every container.
Example patch for a Deployment (namespace and name adjusted as needed):
If multiple containers exist, include each container as a separate entry in the containers array with its own name and resources.limits.For objects managed via manifests (GitOps, IaC), update the YAML instead and apply:
Apply the manifest:
Repeat similar edits for other controllers (StatefulSet, DaemonSet, Job, CronJob) so all their containers define both CPU and memory limits.
  1. Verify compliance: