Interview Prep/DevSecOps/Kubernetes admission control and Pod Security

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.

All DevSecOps questions Roadmap: Policy as code

More on Kubernetes admission control and Pod Security