From PSP to Standards
From PSP to Standards
PodSecurityPolicy was removed in Kubernetes 1.25; its replacement is the Pod Security Standards — three built-in profiles applied per namespace through labels:
- privileged — unrestricted; explicit opt-in for trusted system workloads.
- baseline — blocks known escalations: no hostNetwork/hostPID/hostIPC, no hostPaths, no privileged containers, no capability additions beyond NET_BIND_SERVICE.
- restricted — current best practice:
runAsNonRoot,allowPrivilegeEscalation: false, seccompRuntimeDefault, all capabilities dropped.
kubectl label ns prod \
pod-security.kubernetes.io/enforce=restricted \
pod-security.kubernetes.io/enforce-version=latest
Enforcement happens at admission: a violating pod submission is rejected with a message naming the failed control.
Enforce, Audit, and Warn
Enforce, Audit, and Warn
Each level gets three independent labels:
pod-security.kubernetes.io/enforce— reject violations.pod-security.kubernetes.io/audit— allow, but log violations.pod-security.kubernetes.io/warn— show warnings to whoever submits.
A safe migration runs warn + audit at restricted while enforce stays at baseline, then flips enforce once workloads comply. The -version labels pin the standard applied (for example v1.29) so a cluster upgrade cannot silently tighten rules on you.
Pods satisfy restricted with a matching securityContext:
securityContext:
runAsNonRoot: true
runAsUser: 10001
seccompProfile: { type: RuntimeDefault }
capabilities: { drop: ["ALL"] }
allowPrivilegeEscalation: false
Anything beyond the built-in profiles requires admission webhooks — the standards are deliberately fixed.
Pitfalls and Interview Angles
Pitfalls and Interview Angles
Pitfall 1 — enforcing on legacy namespaces. Running pods are not deleted retroactively, but every reschedule or new deploy starts failing admission. Roll out warn and audit first and burn down the findings.
Pitfall 2 — images that require root. An image built with USER root or an entrypoint assuming uid 0 breaks under restricted; fix the Dockerfile instead of weakening the namespace policy.
Interview-ready: name the three profiles with one control each, distinguish enforce from audit and warn, explain why PSP was replaced (static, cluster-awkward admission policy with poor expressiveness), and point to OPA/Gatekeeper or Kyverno for custom rules beyond the standards.
Quiz
1. Which profile is the strictest Pod Security Standard?
2. What does the enforce-mode label do to a violating pod?
3. How should a namespace be migrated to restricted safely?
Flashcards
Question
Three PSS profiles
Click to reveal answer
Answer
privileged (open), baseline (anti-escalation floor), restricted (non-root, drop caps, seccomp RuntimeDefault).
Question
Mode labels
Click to reveal answer
Answer
enforce rejects, audit logs violations, warn notifies the submitting client.
Question
What replaced PodSecurityPolicy
Click to reveal answer
Answer
Pod Security Admission applying the built-in standards per namespace (PSP removed in 1.25).
Question
restricted securityContext
Click to reveal answer
Answer
runAsNonRoot, allowPrivilegeEscalation false, seccomp RuntimeDefault, capabilities drop ALL.
Revision Notes
Key Takeaways
- 1. Standards are labels on namespaces, evaluated at admission
- 2. Migrate with warn/audit before enforce
- 3. Fix images to run non-root rather than loosening policy
Interview Tips
- • Name one control from each profile to prove you know the differences
- • Explain your migration sequence for an existing namespace with legacy apps
Cheat Sheet
PSS via namespace labels: privileged/baseline/restricted; enforce rejects, audit logs, warn notifies. Migrate warn→audit→enforce; restricted = non-root + drop ALL + seccomp.