Interview Prep/DevSecOps/Kubernetes Security Posture

How do you assign Pod Security Admission levels across namespaces in production?

BeginnerProductionKubernetes Security Posture
Answer

restricted for all application namespaces, baseline only where a documented need exists, privileged only for system namespaces (CNI, CSI drivers, node agents).

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

Set the labels through the namespace provisioning template, and use a Kyverno policy to stop teams from relabelling their namespace to privileged. Pin enforce-version if you want upgrades to never tighten rules unexpectedly.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security Posture