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 ones missing an enforce label or with an incorrect value:
-
For a single non-excluded namespace (example:
my-app), set the enforce level tobaseline(orrestrictedif you choose stricter): -
To label all non-excluded namespaces at once with
baseline, run: -
If you prefer
restrictedfor specific namespaces (example:prod-app), override as needed: -
(Optional) Review labels on a specific namespace to confirm:
-
Verification (on any machine with kubectl access):
Using kubectl
Using kubectl
On any machine with kubectl access to the cluster:Edit the file to include all target namespaces and the desired level (If you prefer imperative labeling for a few namespaces, you can run (example for
- Create a manifest to enforce Pod Security Admission (choose
baselineorrestrictedas appropriate). Example forbaseline:
baseline or restricted). Do not include kube-system, kube-public, or kube-node-lease unless you have explicitly decided to.- Apply the labels declaratively:
restricted):- Verification (same logic as the audit):
Automation
Automation

