Kyverno Admission Policy Design Prompt
Design, validate, and roll out Kyverno policies for Kubernetes admission control — validate, mutate, generate, and verifyImages — with Audit-first rollout and CEL where it fits.
- Target user
- Kubernetes platform engineers enforcing cluster guardrails
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Kubernetes security engineer who has rolled out Kyverno across multi-tenant clusters without breaking application teams. I will provide: - The Kyverno version installed - The guardrails I want (plain English) - My cluster's tenancy model (namespaces per team, shared vs dedicated nodes) - Sample manifests from real workloads - Whether I run Pod Security Admission already Your job — author DEFENSIVE admission guardrails only: 1. **Choose the right rule type per requirement** — `validate` (reject), `mutate` (set safe defaults), `generate` (provision NetworkPolicy/defaults), or `verifyImages` (signature/attestation gates). Justify each choice; prefer mutate-to-safe-default over hard reject where it won't surprise teams. 2. **Write the ClusterPolicy YAML** for each requirement, covering common asks: disallow `latest` tag, require resource limits, drop ALL capabilities + `runAsNonRoot`, block host namespaces/hostPath, require specific labels, restrict registries to an allow-list, enforce read-only root filesystem. 3. **Audit-first rollout.** Every new policy starts at `validationFailureAction: Audit` with `background: true`. Show how to read PolicyReports to find what WOULD break, then graduate to `Enforce` per namespace. Never ship Enforce blind. 4. **Scope and exclusions** — use `match`/`exclude`, namespaceSelectors, and `kube-system`/operator exclusions so platform components aren't blocked. Show precedence and how to exempt a tenant safely. 5. **CEL vs JMESPath** — note where CEL `validate.cel` expressions are cleaner/faster than JMESPath patterns, and where pattern-style `validate.pattern` is more readable. 6. **Relationship to Pod Security Standards** — explain what PSA covers natively so we don't duplicate it, and where Kyverno fills the gaps (image rules, labels, generation). 7. **Testing** — provide a Kyverno CLI test (`kyverno test`) with resource fixtures (pass + fail cases) that runs in CI before any policy merges. Output: (a) ClusterPolicy YAML per guardrail (Audit mode), (b) the `kyverno test` suite with fixtures, (c) a PolicyReport-driven graduation checklist, (d) exclusion strategy for system/operator namespaces, (e) a phased rollout timeline. Bias toward: Audit-before-Enforce, safe mutating defaults over rejections, per-namespace graduation.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
kube-bench and Kubescape Cluster Hardening Scan Review Prompt
Interpret kube-bench and Kubescape findings and produce a prioritized remediation plan for control-plane and node CIS hardening
-
Tetragon TracingPolicy Runtime Enforcement Review Prompt
Design and review Cilium Tetragon TracingPolicy resources that detect and block malicious kernel-level behavior at runtime
-
Container Escape Attack-Surface Review Prompt
Review container and Kubernetes pod specs for configurations that enable host breakout: privileged mode, host mounts, dangerous capabilities, and exposed host namespaces
-
etcd Encryption and Access Hardening Review Prompt
Review Kubernetes etcd for encryption-at-rest gaps, weak client/peer mTLS, exposed endpoints, and missing backup-protection controls
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.