/k8s-skills:k8s-gatekeeper-troubleshootingfrom k8s-skills
Investigates OPA Gatekeeper issues in Kubernetes: denied/warned resources, constraints not enforcing, templates failing to compile, referential policies not firing, mutations not applying, or webhook down. Uses kubectl and proposes fixes, reads first before changing.
Ships in k8s-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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 Secrets.
validation.gatekeeper.sh, or prints a Gatekeeper warning.Hand-offs, by skill name. When the evidence points elsewhere, continue with that skill; if it is not installed, keep going with the steps here and tell the user which skill would help:
k8s-workload-troubleshooting.validate.kyverno.svc-fail, vpol.validate.kyverno):
k8s-kyverno-troubleshooting.Work through the steps in order. Stop when you have the cause and its evidence.
1. Read the denial or warning. The text in square brackets is the constraint's
name: admission webhook "validation.gatekeeper.sh" denied the request: [<constraint>] <message>. A warning reads Warning: [<constraint>] <message>.
2. List templates and constraints. Every constraint kind is its own resource;
constraints lists them all.
kubectl get constrainttemplates
kubectl get constraints
3. Read the constraint: what it matches, its action, its parameters, and the audit's violations.
kubectl get k8srequiredlabels my-constraint -o yaml
kubectl get k8srequiredlabels my-constraint -o jsonpath='{.spec.enforcementAction}{"\n"}{.spec.match}{"\n"}{.spec.parameters}{"\n"}{.status.totalViolations}{"\n"}{.status.violations}{"\n"}'
4. Read the template's status: whether it compiled on every Gatekeeper pod.
kubectl get constrainttemplate k8srequiredlabels -o jsonpath='{.status.created}{"\n"}{range .status.byPod[*]}{.id}{" "}{.errors}{"\n"}{end}'
kubectl get crds | grep constraints.gatekeeper.sh
5. If Gatekeeper itself may be the problem, read its pods, webhooks, Config and logs.
kubectl get deployments,pods -n gatekeeper-system
kubectl get validatingwebhookconfiguration gatekeeper-validating-webhook-configuration -o jsonpath='{range .webhooks[*]}{.name}{" "}{.failurePolicy}{"\n"}{end}'
kubectl get configs.config.gatekeeper.sh -n gatekeeper-system -o yaml
kubectl get namespace my-namespace --show-labels
kubectl logs -n gatekeeper-system deployment/gatekeeper-controller-manager -c manager --tail=100
kubectl logs -n gatekeeper-system deployment/gatekeeper-audit -c manager --tail=100
6. Open the matching reference and follow its steps:
| What you see | Reference |
|---|---|
A denial or warning, violations in a constraint's status, a constraint that does not block (dryrun, warn, scoped, match) | references/constraints.md |
A template that does not compile, no matches for kind, ValidatingAdmissionPolicies Gatekeeper generates | references/templates.md |
| Gatekeeper stopped enforcing, webhook down, exempt namespaces, sync for referential policies, mutation | references/webhook-sync-mutation.md |
What the common findings mean (Gatekeeper 3.23):
denied the request: [<constraint>] <message>: the constraint has
enforcementAction: deny (the default) and the resource violates it. The message is
the template's own text.status.violations but nothing blocked: the constraint is
dryrun (audit only) or warn, or the resource existed before the constraint (the
webhook checks only new requests; the audit finds the rest). status.violations holds
at most 20 entries by default; totalViolations is the full count.byPod[].errors such as ingest_error Could not ingest Rego: ... rego_parse_error: the policy code does not compile. Gatekeeper accepts the template
object but never creates its constraint kind.no matches for kind "<Kind>" in version "constraints.gatekeeper.sh/v1beta1" or
the server could not find the requested resource when applying a constraint: the
kind does not exist yet, because its template is missing or failed to compile.validation.gatekeeper.sh uses failurePolicy: Ignore, so the API server
admits everything while Gatekeeper is unreachable, and only the audit notices.admission.gatekeeper.sh/ignore,
is listed in the Config's excludedNamespaces, or the constraint's match leaves it
out. gatekeeper-system is always exempt.State the cause in one sentence, then the evidence you saw (the denial or violation, the constraint and its action, the template status), then the proposed fix.
Show each fix to the user before running it: what it changes and how to undo it. Make the resource comply in its source (manifest, Helm values, GitOps repository). Changing a constraint's action or match, fixing a template, exempting a namespace and editing Gatekeeper's Config or webhooks change what is enforced for everyone: never run them yourself; hand them to the constraint's owners as proposed fixes. Write each undo with the values you found.
Bring back Gatekeeper's webhook after it was scaled to zero (write the undo with the replicas you found):
Ask first: the agent runs this only after the user approves it.
kubectl scale deployment/gatekeeper-controller-manager -n gatekeeper-system --replicas=3
# Undo: kubectl scale deployment/gatekeeper-controller-manager -n gatekeeper-system --replicas=0
Resources admitted while the webhook was down stay as they are; the audit lists them in
the constraints' status.violations, and they are fixed in their source.
Checked against the Gatekeeper 3.23 documentation and source (v3.23.1):
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub k8s-servant/k8s-skills --plugin k8s-skills31 skills in this plugin
/k8s-aks-troubleshootingUse when a problem is specific to Azure Kubernetes Service (AKS): a cluster or node pool in "Failed" state, an upgrade or scale that fails ("UpgradeFailed", "violate the pod's disruption budget", "QuotaExceeded", "AllocationFailed"), a LoadBalancer Service stuck at <pending> ("SyncLoadBalancerFailed", "AuthorizationFailed"), an Azure Disk or Files PVC that fails ("ProvisioningFailed", "volume node affinity conflict", "Multi-Attach error", "Mount error(13)"), workload identity errors ("AADSTS700016", "AADSTS70021"), CoreDNS edits that AKS reverts, "error dialing backend", Azure Policy denials, or API server access (authorized IP ranges, private clusters, kubelogin, "User does not have access to the resource in Azure"). Investigates with kubectl and read-only az commands, and proposes fixes. Reads first and asks before changing anything./k8s-api-troubleshootingUse when the Kubernetes API server itself refuses or fails a request, before any controller acts on it: "failed calling webhook", "admission webhook ... denied the request", "ValidatingAdmissionPolicy ... denied request", a ReplicaSet with FailedCreate and no pods, an APIService "False (ServiceNotFound)", "FailedDiscoveryCheck" or "MissingEndpoints", "unable to retrieve the complete list of server APIs", a namespace stuck in Terminating, "no matches for kind" or "ensure CRDs are installed first", "strict decoding error: unknown field", a conversion webhook failure, "You must be logged in to the server (Unauthorized)", 429 "too many requests", "etcdserver:" errors, "Request entity too large" or "metadata.annotations: Too long". Investigates with kubectl get, describe, events and the health endpoints, and proposes fixes. Reads first and asks before changing anything.2 plugins in one repository ship this exact skill · first indexed Oct 27, 2026
Other plugins' skills for the same job