Deploy OPA Gatekeeper to a Kubernetes cluster, write a ConstraintTemplate and Constraint to block privileged containers, and test with a dry-run audit

domain: open-policy-agent.github.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install Gatekeeper using the official Helm chart or the release manifest, ensuring the ValidatingWebhookConfiguration and audit controller are deployed
  2. Write a ConstraintTemplate with a CRD schema defining the constraint kind (e.g., K8sNoPrivilegedContainers) and a Rego target rule that checks 'input.review.object.spec.containers[_].securityContext.privileged'
  3. Apply the ConstraintTemplate and wait for the CRD it defines to become available in the cluster before applying the Constraint
  4. Create a Constraint of the generated kind with spec.match targeting the relevant namespaces and spec.enforcementAction set to 'deny' for admission or 'dryrun' for audit-only mode
  5. Apply a test Pod with privileged: true and verify Gatekeeper blocks it in deny mode or records a violation in 'kubectl get constraint <name> -o yaml' under status.violations in dryrun mode

Known gotchas

Related routes

Deploy OPA Gatekeeper and author a ConstraintTemplate plus Constraint to enforce a required annotation on all Kubernetes Deployments
security/compliance · 6 steps · unrated
Configure OPA Gatekeeper with a ConstraintTemplate and Constraint to enforce that all Deployments have a specified owner label and block admission for non-compliant resources
open-policy-agent.github.io · 5 steps · unrated
Write and test an OPA Gatekeeper ConstraintTemplate with Rego v1 syntax
open-policy-agent.github.io/gatekeeper · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans