Pod Security Admission evaluates Pods against built-in privileged, baseline, or restricted standards. Namespace labels select enforce, warn, and audit behavior independently. Enforce rejects new nonconforming Pods; it does not retroactively terminate an existing Pod. A policy version label can hold the standard at a reviewed Kubernetes release while the cluster upgrades, so a security rule change does not arrive as an accidental side effect of a control-plane upgrade.
Pod Security Admission: stage warnings before a namespace denies Pods
Operational decision
A receipt-processing namespace contains application Pods and one legacy diagnostic sidecar. Begin with baseline enforcement and restricted warn and audit labels in a disposable namespace. Submit every Deployment, Job, init container, and debug-container workflow through server-side dry-run. Gather warnings and audit annotations, then fix or separate workloads with a real need for exceptions. The fragment pins the example labels to a cluster version; replace that version with one supported by the target control plane. Before moving enforce to restricted, calculate the number of Pods that a rolling restart would need to recreate and prove those manifests pass admission. Test a rollout and rollback, not only a currently running Pod. Keep highly privileged agents in separately governed namespaces and restrict who can create workloads there. Record every exemption with an owner and expiry; a broadly permissive namespace can bypass the intended boundary.
apiVersion: v1
kind: Namespace
metadata:
name: receipt-processing
labels:
pod-security.kubernetes.io/enforce: baseline
pod-security.kubernetes.io/enforce-version: v1.36
pod-security.kubernetes.io/warn: restricted
pod-security.kubernetes.io/warn-version: v1.36
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/audit-version: v1.36Cost and verification
Warning and audit stages cost review time but expose blocked workloads before an outage. An abrupt enforce change can stall rollouts even while old Pods remain healthy, leaving a service unable to replace failed replicas. Measure dry-run violations, denied Pod creations, exception age, and replacement capacity under a simulated node drain. Pinning a policy version reduces surprise but requires an explicit review when the cluster standard advances.
Common Mistakes
- Do not use a running Pod as proof that its replacement will pass a new enforce policy.
- Do not exempt a broad namespace merely to keep one privileged agent running.
- Do not copy the sample version label into a cluster that does not support it.
Connected lessons
- DevOps: delivery, infrastructure, and reliable operations
- Kubernetes admission policy: reject an unsafe workload before scheduling
- Container runtime restrictions: remove privileges a service does not use
- Cluster upgrade drill: preserve a path through each version step
- Policy exceptions: make a temporary bypass expire and prove its scope
