Interview Prep/DevSecOps/Kubernetes admission control and Pod Security

Gatekeeper constraint fails to apply: `no matches for kind "K8sRequiredLabels" in version "constraints.gatekeeper.sh/v1beta1"`

BeginnerTroubleshootingKubernetes admission control and Pod Security
Answer

Likely causes → The ConstraintTemplate was not applied yet or failed to compile, so the CRD for the constraint kind does not exist. In GitOps, ordering applied them together.

Diagnose →

kubectl get constrainttemplate k8srequiredlabels -o jsonpath='{.status}' | jq
kubectl get crd | grep constraints.gatekeeper.sh

Fix → Apply the template first, fix Rego compile errors shown in status.byPod[].errors, then the constraint.

Prevent → Argo CD sync waves (templates wave 0, constraints wave 1) or SkipDryRunOnMissingResource=true.

All DevSecOps questions Roadmap: Policy as code

More on Kubernetes admission control and Pod Security