k8s-gatekeeper-troubleshootinglisted
Install: claude install-skill k8s-servant/k8s-skills
# 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.
The commands use placeholders: `my-namespace`, `my-app`, `k8srequiredlabels` (a
template) and `my-constraint` (a constraint of kind `K8sRequiredLabels`). Replace them
with the real names. The built-in `view` role cannot read Gatekeeper's objects
(Gatekeeper adds nothing to it); if the commands are forbidden, say so and ask the user
for the constraint and template status. Never read S