You must roll out Pod Security Standards on a cluster with 80 existing namespaces. How do you avoid breaking workloads?
IntermediateScenarioKubernetes Security
Answer
Situation read → Pod Security Admission can warn and audit before it enforces. Use that.
What I'd do →
- Label all namespaces with warn and audit at
restricted, enforce atbaseline:
kubectl label ns --all \
pod-security.kubernetes.io/enforce=baseline \
pod-security.kubernetes.io/warn=restricted \
pod-security.kubernetes.io/audit=restricted --overwrite
- Dry-run first:
kubectl label --dry-run=server --overwrite ns orders pod-security.kubernetes.io/enforce=restrictedlists violating pods. - Fix manifests team by team (runAsNonRoot, drop capabilities, seccomp
RuntimeDefault). - Move namespaces to
enforce=restrictedonce clean; keep system namespaces atprivilegedwith a documented reason.
Why → Warnings in kubectl output and audit logs give teams time to fix things before anything is blocked.
Interview tip → PodSecurityPolicy was removed in 1.25; PSA is the built-in replacement.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate