Skip to content
Back to skills

Kyverno Knowledge Patch

ASecurity

Kyverno

  • 25 stars
  • 0 votes
  • 0 copies
  • 10 views
  • Added September 5, 2026
developmentgoexpresskubernetesgitapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill kyverno-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kyverno Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kyverno Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-kyverno-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-kyverno-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: kyverno-knowledge-patch
description: Kyverno
version: "1.20.0"
license: MIT
metadata:
  author: Nevaberry
---


# Kyverno Knowledge Patch

Load this skill when migrating Kyverno policies, authoring CEL policies and
exceptions, verifying images, evaluating policies with the CLI, or configuring
reports and controllers. Use the topic references for examples and the version
context of API, CLI, and controller behavior.

## Reference index

| Reference | Topics |
| --- | --- |
| [Policy APIs and Exceptions](references/policy-apis.md) | API versions, namespace scope, validation, mutation, generation, deletion, autogeneration, exceptions |
| [CEL Libraries and Service Authorization](references/cel-and-authorization.md) | Resource lookups, HTTP controls, global context, utility functions, evaluation limits, Authz Server, Go SDK |
| [Image Verification](references/image-verification.md) | Attestors, certificates, extraction, registry credentials, Cosign, attestations, OCI referrers, background scans |
| [CLI, Reports, Events, and Metrics](references/cli-reports-observability.md) | Local evaluation, OCI bundles, JSON mutation, output, traces, OpenReports, Events, Prometheus |
| [Operations and Upgrades](references/operations-and-upgrades.md) | Legacy API migration, Helm upgrades, support window, controller configuration, policy charts, generation ownership |

## Breaking changes and deprecations

Kyverno 1.20 stops running legacy `kyverno.io` policies, including
`ClusterPolicy` and legacy cleanup policies, in admission, background processing,
and reporting. Creates and spec updates are blocked. Legacy CRD schemas remain
retained and frozen, and old report results can remain after upgrading.

Helm gates installs and upgrades by default when legacy policy resources remain
and preserves their CRDs during pruning. Check for remaining legacy policies and
orphaned webhook configurations before a GitOps or manifest-based upgrade.

The CLI removes legacy policy execution and authoring. Migrate legacy policy
manifests to CEL policies before passing them to `kyverno apply` or `kyverno test`.
Legacy `kyverno.io` Go policy types and their generated clients are removed.
The `json scan` command and test API support for `kyverno-json` are removed.

Kyverno emits deprecation warnings for legacy CRD versions and supports enforcing
those warnings in the CLI. Update legacy `v2beta1` manifests to a supported API
version for the resource kind.

Namespaced policies can no longer read global context entries. Review policies
that depend on those entries before upgrading. `GlobalContextEntry` projections
accept CEL expressions; the `jmesPath` projection field is deprecated, and Kyverno
records its use.

Policy reporting supports `openreports.io`, including in Reports Server and Policy
Reporter. Point consumers at that group when adopting it; `wgpolicyk8s.io` is
slated for deprecation. The CLI emits namespaced OpenReports with `kind: Report`;
update scripts that filter its report output by kind.

## CEL policy APIs and scope

Use `apiVersion: policies.kyverno.io/v1` for `ValidatingPolicy`, `MutatingPolicy`,
`GeneratingPolicy`, `ImageValidatingPolicy`, `DeletingPolicy`, their namespaced
variants, and CEL `PolicyException`. `policies.kyverno.io/v1beta1` remains supported
during the transition. Reference examples retain their attributed API versions.

| Task | Policy and expression location |
| --- | --- |
| Validate resources | `ValidatingPolicy`: CEL in `spec.validations`, matching through `spec.matchConstraints` |
| Mutate resources | `MutatingPolicy`: apply-configuration patches in `spec.mutations` |
| Generate resources | `GeneratingPolicy`: `generator.Apply(namespace, resources)` in `spec.generate[].expression` |
| Delete existing resources | `DeletingPolicy`: cron in `spec.schedule`, CEL selection in `spec.conditions` |
| Verify images | `ImageValidatingPolicy`: image reference matching, signatures, and attestations |

Set `metadata.namespace` on namespaced policies to govern that namespace.
`NamespacedMutatingPolicy` and `NamespacedGeneratingPolicy` let namespace owners
define scoped mutation and generation. Namespaced mutation and cleanup policies
can only target resources in their own namespace.

`ValidatingPolicy` can generate a Kubernetes `ValidatingAdmissionPolicy`.
`MutatingPolicy` can generate a Kubernetes `MutatingAdmissionPolicy` with automatic
bindings. Both support API server enforcement through those generated policies.

## Background processing and autogeneration

Creating or updating a `ValidatingPolicy` triggers a background scan of existing
matching resources in addition to periodic scans. `MutatingPolicy` background scans
can run on creation, update, and a periodic schedule.

Background `mutateExisting` evaluation checks the policy's `matchConditions` and
skips mutation when they fail. Kyverno preserves configured mutation reinvocation.
`MutatingPolicy` resolves subresource triggers declared in `matchConstraints`, and
the CLI passes the resolved subresource to CEL policy evaluation.

Pod-controller autogeneration can be explicitly enabled or disabled in policy
configuration. Autogeneration can extend Pod rules to custom workload CRDs such
as JobSet by extracting embedded Pod templates. Admission covers autogenerated
`NamespacedValidatingPolicy` rules as well as original rules. Background image
scans discover workloads matched by autogenerated `ImageValidatingPolicy` and
`NamespacedImageValidatingPolicy` rules.

`GeneratingPolicy` supports CEL loops for multiple items or target namespaces.
Its synchronization setting carries through to `UpdateRequest` resources; enabled
synchronization recreates generated resources after repeated deletions. It also
handles custom resources and multiple triggers, preserving trigger associations.
`generateExisting` honors wildcard entries in `excludeResourceRules`.

Deletion policies process all pages when listing namespaced resources. Cleanup
and deleting controllers honor configured `resourceFilters`. Reusable deletion
expressions belong in `spec.variables` and are referenced as `variables.<name>`.

## Exceptions and evaluation failures

Identify an exception's policy by `kind` and `name` in `spec.policyRefs`; scope it
with CEL in `spec.matchConditions`. Kyverno validates those CEL expressions.
Keep CEL exceptions in the configured `exceptionNamespace` when that restriction
is set. Generated `ValidatingAdmissionPolicy` resources honor the same exception
eligibility checks as Kyverno's runtime.

Use `PolicyException.spec.images` for image references or patterns. A
`ValidatingPolicy` can use `exceptions.allowedImages` to exempt individual images
from an explicit `:latest` tag check. A matching exception supplies
`spec.allowedValues` as `exceptions.allowedValues`. Matching exceptions default to
`skip` in reports; set `spec.reportResult` to `pass` to report a pass.

CEL exceptions can specify compensating controls and use the `resource` library
for Kubernetes lookups. Autogeneration rewrites Pod field paths in exception match
conditions to the embedded Pod template; controller metadata paths remain unchanged.

The `ValidatingPolicy` admission handler honors `failurePolicy: Ignore` for runtime
evaluation errors. Image policies set `spec.failurePolicy` to `Ignore` to continue
admission if evaluation fails, and `spec.webhookConfiguration.timeoutSeconds`
configures their webhook timeout.

## Image verification

`ImageValidatingPolicy` extracts references from JSON, matches them with globs or
CEL, and verifies signatures and attestations. Empty `matchConstraints` are
rejected; declare the resources the policy should match.

Use `attestors[].notary.certs.value` for a literal certificate or an expression
for dynamic certificates. For an SBOM published as an OCI referrer, declare a named
`spec.attestations` entry with `referrer.type: sbom/cyclone-dx`. Keyless signing
supports `additionalExtensions` for additional signing certificate extensions.

Wildcard extraction skips scalar branches. An `imageExtractors` entry's `filter`
restricts which elements of a wildcard-matched array contribute image references.
Registry credentials for a namespaced image policy are scoped to its namespace.

Verification runs at admission even when earlier processing supplied verification
metadata, and registry reads are capped. Cosign v3 signatures are supported, and
signature annotations are verified with both Cosign v2 and v3.
`ImageValidatingPolicy` selects the newest matching attestation; image verification
fails closed for unverified OCI referrers.

## CEL access and service authorization

The CEL libraries support Kubernetes object reads, external HTTP calls, service
account identity parsing, global context reads, image reference parsing, and OCI
registry metadata. The reference includes hash, rounding, certificate, random
string, list-to-map, JSON, YAML, time, and gzip utilities.

Kyverno libraries such as `resource` work in `spec.matchConditions`; for admission,
Kyverno evaluates them after the request reaches its webhook. HTTP calls from
namespaced policies are disabled by default and require explicit configuration
flag opt-in. Loopback and metadata service addresses are blocked by default;
destination allowlists and blocklists are configurable for both policy scopes.
The HTTP blocklist also applies to legacy `apiCall.service` context calls.

Outbound HTTP CEL calls carry a dedicated scoped token to prevent receiving
services from impersonating controllers. Kyverno validates Kubernetes API paths
and canonicalizes `apiCall` paths. CEL evaluation cost, wildcard matching, and
variable substitution are bounded; policies exceeding the limits can fail.

The Authz Server returns allow or deny decisions for Envoy's External Authorization
filter and can run as a standalone authorization server for HTTP services.
The Go SDK loads and compiles policies and evaluates service requests in middleware,
gateways, or sidecars, returning structured results with optional metrics and hooks.

## CLI workflows

`kyverno apply` and `kyverno test` support cleanup policies, HTTP and Envoy
authorization policies, and `MutatingPolicy` `mutateExisting` rules.
Use `--exceptions-with-policies` to supply exceptions alongside policies.
A `ValidatingPolicy` can evaluate arbitrary JSON as `object`; a `MutatingPolicy`
in JSON mode can patch arbitrary JSON documents.

Package CEL policies in OCI bundles for `kyverno apply` and `kyverno test`.
Use `kyverno oci validate` for CEL-aware validation, `kyverno oci inspect` to examine
a bundle, and `kyverno oci resolve` to resolve policy sets named in its descriptor.

Use `--explain` to inspect decisions and `--output-file` or `--output-dir` to choose
where `kyverno apply` writes mutated manifests. `kyverno version` supports JSON and
YAML output. With `--cluster`, CLI CEL engines resolve live Namespace objects.
The CLI resolves `NamespacedValidatingPolicy` match constraints, and `kyverno test`
retains generation `skip` results so test expectations can assert them.

## Reports and diagnostics

Use `--allowedResults` to select stored report outcomes. The
`reports.kyverno.io/disabled` label suppresses ephemeral reports and PolicyReports
independently of enforcement on a CEL policy, `ValidatingAdmissionPolicy`, or
`MutatingAdmissionPolicy`. Any label value works;
removing it resumes reporting.

Inspect CEL policy Events with `kubectl get events`. Set `successEventActions` in
the ConfigMap to select success actions that emit Events. The admission controller
can log decision traces when tracing is enabled. `/metrics` supports TLS scraping.

Execution histograms expose `_bucket`, `_sum`, and `_count` series. Use
`execution_cause` to distinguish `admission_request` from `background_scan`.
The validating-policy histogram uses uppercase `PASS` and `FAIL` in `result`:

```promql
rate(kyverno_validating_policy_execution_duration_seconds_count{result="FAIL"}[5m])
```

This measures failed policy evaluations per second over the last five minutes.
The observability reference lists the metric names, labels, report sources, and
background-report circuit breaker behavior.

Files in this skill

  • SKILL.md9.8 KB
  • coverage.json719 B
  • references/cel-and-authorization.md3.6 KB
  • references/cli-reports-observability.md4.1 KB
  • references/image-verification.md3.5 KB
  • references/operations-and-upgrades.md3.1 KB
  • references/policy-apis.md6.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.