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

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. Author a ConstraintTemplate that defines a new CRD kind and includes a Rego policy in the spec.targets block that checks for the required label key in the Deployment metadata and generates a violation message if absent
  2. Apply the ConstraintTemplate to the cluster and wait for the custom CRD to be established by Gatekeeper before proceeding
  3. Create a Constraint manifest of the new CRD kind with spec.match rules selecting the Deployment resource type and the namespaces or namespace selectors where the policy should apply, and set enforcementAction to deny
  4. Test the constraint by applying a Deployment without the required label and confirming the API server rejects it with Gatekeeper's violation message
  5. Apply a compliant Deployment with the owner label and verify it is admitted, then inspect the Constraint status for audit results showing existing non-compliant resources

Known gotchas

Related routes

Write an OPA Gatekeeper ConstraintTemplate and Constraint to require resource labels
open-policy-agent.github.io/gatekeeper · 6 steps · unrated
Deploy OPA Gatekeeper and author a ConstraintTemplate plus Constraint to enforce a required annotation on all Kubernetes Deployments
security/compliance · 6 steps · unrated
Author an OPA Gatekeeper ConstraintTemplate and Constraint to enforce image signature requirements in Kubernetes
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