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.
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