k8s-gatekeeper-troubleshooting
OPA Gatekeeper troubleshooting
Find out why Gatekeeper denies, warns about or does not police a resource, and propose a fix. Read first, ask before changing. Run the investigation commands freely. Run a command under an "Ask first" line only after the user approves that exact command; if your credentials do not allow it, give it to the user to run. Never run a "Proposed fix"; hand it to the user.
A ConstraintTemplate holds the policy code (Rego, or CEL under
K8sNativeValidation) and makes Gatekeeper create a new kind in
constraints.gatekeeper.sh (for example K8sRequiredLabels). A constraint of that
kind says where the policy applies (spec.match), with which parameters, and what
happens on a violation (spec.enforcementAction: deny, dryrun, warn or
scoped). The admission webhook checks new requests; the audit checks what already
exists and writes the results into each constraint's status.
A constraint is a guardrail someone chose on purpose. The usual fix is to make the resource comply; changing, scoping or exempting a constraint is a decision for its owners.