Implementing Pod Security Admission

1. Understanding Pod Security Standards

ProfileDescription
privilegedUnrestricted
baselineBlocks known privilege escalations
restrictedHardened best-practice (runAsNonRoot, drop ALL caps, seccomp RuntimeDefault)

2. Using Pod Security Admission

Note: PSA is built-in since 1.25 (replaced PodSecurityPolicy). Enforced per namespace via labels.

3. Configuring Namespace Labels

kubectl label ns prod \
  pod-security.kubernetes.io/enforce=restricted \
  pod-security.kubernetes.io/enforce-version=latest \
  pod-security.kubernetes.io/audit=restricted \
  pod-security.kubernetes.io/warn=restricted

4. Setting Enforce Level

LabelBehavior
enforceReject non-compliant pods
auditAllow but log to audit
warnAllow but return warning to user

5. Setting Audit Level

kubectl label ns dev pod-security.kubernetes.io/audit=baseline

6. Setting Warn Level

kubectl label ns dev pod-security.kubernetes.io/warn=restricted

7. Controlling Host Namespaces

Fieldbaselinerestricted
hostNetworkForbiddenForbidden
hostPIDForbiddenForbidden
hostIPCForbiddenForbidden

8. Restricting Volume Types

baseline blocksrestricted allows
hostPathconfigMap, secret, downwardAPI, projected, emptyDir, PVC, CSI ephemeral

9. Configuring Allowed Capabilities

ProfileAllowed
baselineDefault container caps (AUDIT_WRITE, CHOWN, ...)
restrictedOnly NET_BIND_SERVICE; must drop ALL

10. Migrating from PodSecurityPolicy

PSP ConceptPSA Equivalent
runAsNonRootrestricted profile
volumes allowlistrestricted/baseline rules
RBAC bindingNamespace labels
MutationNot supported — use Kyverno/Gatekeeper
Note: PodSecurityPolicy removed in 1.25 DEPRECATED.