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 missing an enforce label or using an incorrect value (ignore kube-system, kube-public, kube-node-lease if desired):
  2. For a single noncompliant namespace, set the Pod Security Admission enforce label to baseline (or restricted if your policy requires that) using kubectl:
    Replace my-namespace with the actual namespace name.
  3. If you want to update all noncompliant namespaces at once to baseline, run:
  4. For namespaces where you want restricted instead of baseline, label them explicitly:
  5. (Optional) If you manage namespaces via manifests or GitOps, ensure each Namespace manifest includes the enforce label so changes persist:
  6. Verification (on any machine with kubectl access): rerun the audit command and confirm all relevant namespaces report is_compliant=true:
On any machine with kubectl access:
  1. Identify noncompliant namespaces (same as audit):
  1. Patch a specific namespace to enforce baseline (example: dev-namespace):
To enforce restricted instead:
  1. Declarative manifest example (preferred for GitOps/IaC):
Create namespace-dev-namespace.yaml:
Apply it:
  1. Bulk label all existing non-system namespaces to baseline:
  1. Verification (re-run compliance-style check):