Enabling `enforce=restricted` on a namespace did not evict the existing non-compliant pods
BeginnerTroubleshootingKubernetes admission control and Pod Security
Answer
Likely causes → Pod Security Admission is admission-time only; it never touches running pods. They fail only when recreated.
Diagnose → The kubectl label command printed warnings about existing pods; or dry-run it again with --dry-run=server.
Fix → Fix the workloads and roll them (kubectl rollout restart deploy -n prod) in a controlled window so you find failures now, not during a node drain at 3 a.m.
Prevent → Audit first with audit/warn labels and fix everything before enforcing.
More on Kubernetes admission control and Pod Security
`Error from server: admission webhook "validate.kyverno.svc-fail" denied the request: policy Deployment/prod/api for resource violation: require-run-as-nonroot`BeginnerPods do not appear, but `kubectl apply` of the Deployment succeededBeginner`pods "api-7d9" is forbidden: violates PodSecurity "restricted:latest": allowPrivilegeEscalation != false, unrestricted capabilities, seccompProfile`Beginner`Error from server (InternalError): Internal error occurred: failed calling webhook "validation.gatekeeper.sh": ... context deadline exceeded` blocks every deployIntermediateKyverno is down and now the whole cluster, including Kyverno's own namespace, cannot be fixed because writes are rejectedAdvancedGatekeeper constraint is created but violations are not blocked; `kubectl get constraint` shows `TOTAL-VIOLATIONS: 12`Intermediate