Gatekeeper constraint is created but violations are not blocked; `kubectl get constraint` shows `TOTAL-VIOLATIONS: 12`
IntermediateTroubleshootingKubernetes admission control and Pod Security
Answer
Likely causes → The constraint's enforcementAction is dryrun or warn, or its match does not include the kinds/namespaces you expect.
Diagnose →
kubectl get k8srequiredlabels require-team -o yaml | yq '.spec.enforcementAction, .spec.match'
kubectl get k8srequiredlabels require-team -o jsonpath='{.status.violations}' | jq
Fix → After fixing existing violators, set enforcementAction: deny and ensure match.kinds has the right apiGroups (apps for Deployments, "" for Pods).
Prevent → Promote constraints dryrun → warn → deny with violation count at zero as the gate.
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`BeginnerEnabling `enforce=restricted` on a namespace did not evict the existing non-compliant podsBeginner`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 rejectedAdvanced