Skip to main content

More Info:

Verifies each namespace is labeled with pod-security.kubernetes.io/enforce set to baseline or restricted so the built-in Pod Security Admission controller rejects unsafe pods.

Risk Level

High

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. On any machine with kubectl access, list all namespaces and identify those without an enforce label set to baseline or restricted (excluding default system namespaces):
  2. For each non-compliant namespace you want at baseline, add or update the enforce label:
  3. For each namespace you want at restricted (stricter than baseline), add or update the enforce label:
  4. Optionally protect against accidental downgrade by setting the audit and warn levels to match the enforce level (example for restricted):
  5. If you manage namespaces via manifests or GitOps, mirror the change by adding a labels block like this to each Namespace manifest you updated, then apply with kubectl apply -f:
  6. Verification (on any machine with kubectl access): run the original audit and confirm that all non-system namespaces show enforce=baseline or enforce=restricted and is_compliant=true:
On any machine with kubectl access:
  1. Identify noncompliant namespaces (excluding system namespaces):
  1. Label each noncompliant namespace to enforce baseline (example for dev, test, prod—adjust names as needed):
If you prefer restricted for a namespace, use:
  1. (Optional, declarative) Create or update namespace manifests to include the label, then apply:
dev-namespace.yaml:
Apply:
  1. Verification (same as audit, run on any machine with kubectl):