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 without an enforce label set to baseline or restricted (excluding default system namespaces):
-
For each non-compliant namespace you want at baseline, add or update the enforce label:
-
For each namespace you want at restricted (stricter than baseline), add or update the enforce label:
-
Optionally protect against accidental downgrade by setting the audit and warn levels to match the enforce level (example for restricted):
-
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:
-
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:
Using kubectl
Using kubectl
On any machine with kubectl access:If you prefer Apply:
- Identify noncompliant namespaces (excluding system namespaces):
- Label each noncompliant namespace to enforce
baseline(example fordev,test,prod—adjust names as needed):
restricted for a namespace, use:- (Optional, declarative) Create or update namespace manifests to include the label, then apply:
dev-namespace.yaml:- Verification (same as audit, run on any machine with kubectl):
Automation
Automation

