Use Gatekeeper's ExpansionTemplate to validate Pod-targeting constraints against Deployments and other higher-level controllers before they create Pods

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

Steps

  1. Define an ExpansionTemplate custom resource specifying which parent resource kind (e.g., Deployment) expands into which child kind (Pod), including the path to the embedded Pod template.
  2. Gatekeeper generates temporary, non-persisted 'expanded' Pod resources from the parent both at admission-webhook time and during audit, then evaluates Pod-targeting Constraints against those expanded resources.
  3. If a mutating webhook or controller normally alters the Pod spec before real creation, mirror that behavior using Gatekeeper's Mutation feature so the expanded resource matches what will actually be created.
  4. Test expansion configuration locally with the gator expand CLI before applying it to a cluster.
  5. Tune --audit-interval and --constraint-violations-limit so violations surfaced against expanded Pods, along with regular audit findings, appear in each Constraint's status field at a reasonable frequency and volume.

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
Author an OPA Gatekeeper ConstraintTemplate and Constraint to enforce image signature requirements in Kubernetes
open-policy-agent.github.io/gatekeeper · 6 steps · unrated
Deploy OPA Gatekeeper to a Kubernetes cluster, write a ConstraintTemplate and Constraint to block privileged containers, and test with a dry-run audit
open-policy-agent.github.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ 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