Learn: Policy & Admission — reference
A lookup page. The orientation covers the model behind it.
The engine
Section titled “The engine”- Kyverno v1.18.1, HA, on the cluster’s admission webhook — evaluates
every resource create/update. It layers above the native Pod Security Admission
baselinefloor: PSA is the backstop, Kyverno expresses what PSA can’t — registry scoping, hostname allow-lists, per-product rules. - The
policymodule holds no team data. Per-product values are derived from theProductregistry (fileset+yamldecode) at apply time.
The three verbs
Section titled “The three verbs”| Verb | What it does | Example policies |
|---|---|---|
| validate | reject a non-compliant resource at admission | disallow-latest-tag, require-requests-limits, require-pod-probes, restrict-image-registries, restrict-images-<env>, require-prod-replica-floor |
| mutate | rewrite the resource on the way in (inject safe defaults) | mutate-pod-defaults (drop caps, allowPrivilegeEscalation:false, seccomp:RuntimeDefault, automount off), mutate-workload-labels (team), mutate-topology-spread |
| generate | create a companion resource alongside it | generate-workload-pdb (a maxUnavailable:1 PDB per workload) |
The policy catalog (shape)
Section titled “The policy catalog (shape)”- Baseline (platform-wide, Phase 1): latest-tag, requests/limits, probes, seccomp, privilege-escalation, registry allow-list, default-namespace, wildcard-RBAC, cluster-admin binding, workload naming/labels.
- Mutate (Phase 2): securityContext + automount defaults,
teamlabel, topology spread. - Generate: the per-workload PodDisruptionBudget.
- Per-product (derived, per environment namespace):
restrict-images-<team>-<product>-<stage>(only…/team-<team>/<product>-*images) andrestrict-route-hostnames-<…>(only the Environment’s hostnames). Owned by the Environment Composition — rendered with the namespace. - Supply chain (Phase 3, cosign keyless, Enforce):
verify-images-product-<team>-<product>(signed) +verify-attestations-product-<team>-<product>(SBOM + SLSA provenance). Platform-owned, per product. - Governance:
restrict-environment-control-plane(only platform principals — GitOps/ArgoCD,crossplane-system, and the deployer — may manageXEnvironment/ProviderConfig; environments cannot),restrict-environment-envelope,restrict-over-budget-provisioning.
Full per-cluster catalog + status: kyverno-policy-catalog.md.
Audit-first → Enforce
Section titled “Audit-first → Enforce”- Audit: violations recorded as
PolicyReports; resource admitted; webhook fails open (failurePolicy: Ignore). This is how you see what would break before it does. - Enforce: violations rejected; webhook fails closed (
Fail) — thevalidate.kyverno.svc-failyou see in a rejection. The flip is a deliberate, per-policy step.
Gotchas
Section titled “Gotchas”- ⚠️ Enforce/Audit lives in the rule, not the spec. In v1.18 it’s each rule’s
validate.failureAction. The top-levelspec.validationFailureActionis deprecated and defaults toAudit, sokubectl get clusterpolicy -o …spec.validationFailureActionlies — it showsAuditeven where rules Enforce. Read the per-rule field, or just test admission. This asymmetry is a latent fail-open risk on a security control. - A per-policy
matchConditionsdoesn’t skip the aggregated webhook. Kyverno serves all policies through one aggregated webhook. To make it ignore a resource you need a global engine matchCondition, not a per-policy one. - A
generaterule’s match is immutable. You can’t change an existing generate rule’s match in place — add a new rule. - Availability policies don’t match
Rolloutby default.require-prod-replica-floor,generate-workload-pdb, andmutate-topology-spreadonly matchargoproj.io/v1alpha1/Rolloutwhenenable_rollout_kind = true(default off — a Kyverno rule can’t name an absent CRD). Pod-level policies cover Rollout pods automatically via ReplicaSet autogen. See the Delivery reference. - The platform exempts itself. System namespaces (kube-system, kyverno, argocd, karpenter, …) are excluded so admission can never block the platform’s own components.
Glossary
Section titled “Glossary”- Admission — the API-server checkpoint every resource crosses before storage; where Kyverno runs.
ClusterPolicy— a cluster-scoped Kyverno policy (validate / mutate / generate rules).PolicyReport— Kyverno’s per-resource pass/fail record (how Audit surfaces violations).- failureAction — per-rule
Enforce(reject) vsAudit(record only). - PSA (Pod Security Admission) — Kubernetes’ native pod-security tiers; the
baselinefloor under Kyverno. - autogen — Kyverno auto-deriving pod rules for controllers (Deployment→ReplicaSet→Pod), so a pod policy covers workloads without you writing the controller variants.
Go deeper
Section titled “Go deeper”- Kyverno policy catalog (as-built, per-cluster).
- Author policies: the
kyverno-policy-authoringskill. Write compliant workloads:authoring-k8s-workloads+compliant-deployment.yaml. - Substrate: Kyverno · admission control · Pod Security Admission.