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
HighAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
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):
-
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-namespacewith the actual namespace name. -
If you want to update all noncompliant namespaces at once to baseline, run:
-
For namespaces where you want restricted instead of baseline, label them explicitly:
-
(Optional) If you manage namespaces via manifests or GitOps, ensure each Namespace manifest includes the enforce label so changes persist:
-
Verification (on any machine with kubectl access): rerun the audit command and confirm all relevant namespaces report
is_compliant=true:
Using kubectl
Using kubectl
On any machine with kubectl access:To enforce Apply it:
- Identify noncompliant namespaces (same as audit):
- Patch a specific namespace to enforce
baseline(example:dev-namespace):
restricted instead:- Declarative manifest example (preferred for GitOps/IaC):
namespace-dev-namespace.yaml:- Bulk label all existing non-system namespaces to
baseline:
- Verification (re-run compliance-style check):
Automation
Automation

