Pod Security Standards and Admission

Pod Security Standards and Admission

Pod Security Standards define three levels. Pod Security Admission (built in) enforces them per namespace with labels.

LevelAllowsFor
privilegedeverythingsystem namespaces, CNI, storage drivers
baselineno privileged, no host namespaces, no hostPath, no dangerous capabilitiesmost legacy apps
restrictedbaseline + non-root, drop ALL, no privilege escalation, seccompnew apps - the target
ModeEffect
enforceviolating Pods are rejected
auditallowed, recorded in the audit log
warnallowed, the user sees a warning
apiVersion: v1
kind: Namespace
metadata:
  name: shop
  labels:
    pod-security.kubernetes.io/enforce: baseline
    pod-security.kubernetes.io/enforce-version: latest
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/audit: restricted

The typical rollout: warn/audit restricted, enforce baseline - then fix the warnings and raise enforce.

# what would break if I enforced restricted here?
kubectl label --dry-run=server --overwrite ns shop \
  pod-security.kubernetes.io/enforce=restricted
Warning

PSA checks Pods. A Deployment with a violating template is accepted - its ReplicaSet then fails to create Pods (FailedCreate). Look at the ReplicaSet events, or use warn which also checks workload templates.

References