Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Kyverno Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-kyverno-knowledge-patch-nevaberry-plugins)
---
name: kyverno-knowledge-patch
description: Kyverno
version: "1.20.0"
license: MIT
metadata:
author: Nevaberry
---
# Kyverno compatibility guidance
Load this skill when migrating legacy policies, writing CEL policies and exceptions,
verifying images, evaluating policies locally, or operating reports and controllers.
The references contain policy examples, API details, and version-specific behavior.
## Reference index
| Reference | Topics |
| --- | --- |
| [Policy APIs and Migration](references/policy-apis-and-migration.md) | Legacy removal, API versions, namespace scope, validation, mutation, generation, cleanup, autogeneration |
| [CEL and Policy Exceptions](references/cel-and-exceptions.md) | CEL libraries, evaluation limits, global context, exceptions, service authorization, Go integration |
| [Image Verification and HTTP Security](references/image-and-http-security.md) | Attestors, signatures, attestations, extraction, credentials, HTTP controls, API paths |
| [CLI, Reports, and Operations](references/cli-reports-and-operations.md) | Local evaluation, OCI bundles, output, reports, metrics, Events, Helm, controller settings, patch support |
## Legacy migration and removed interfaces
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 are retained and frozen.
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`.
The legacy Go policy types and generated clients have also been removed.
The `json scan` command and test API support for `kyverno-json` are removed.
`GlobalContextEntry` projections accept CEL expressions. The `jmesPath` projection
field is deprecated, and Kyverno records its use.
Reporting supports `openreports.io`; point report consumers at that group when
adopting it because `wgpolicyk8s.io` is slated for deprecation.
The CLI emits namespaced OpenReports resources with `kind: Report`;
update scripts that filter report output by kind.
## Scope and evaluation constraints
- Namespaced policies can no longer read global context entries. Review policies
that depend on those entries before upgrading.
- Namespaced mutation and cleanup policies can only target resources in their
own namespace. Registry credentials for namespaced image policies are scoped
to their namespace.
- HTTP calls from namespaced policies are disabled by default and require explicit
opt-in through configuration flags. Loopback and metadata service addresses are
blocked by default; destination allowlists and blocklists are configurable for
both cluster-scoped and namespaced policies.
- 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 caps CEL evaluation cost and bounds wildcard matching and variable
substitution. Policies that exceed the limits can fail evaluation.
- An `ImageValidatingPolicy` with empty `matchConstraints` is rejected.
Declare the resources the policy should match.
## CEL policy authoring
Use `apiVersion: policies.kyverno.io/v1` for the CEL policy kinds, their namespaced
variants, and CEL `PolicyException`. The beta API remains supported during the
transition. Set `metadata.namespace` on namespaced policies to scope them.
| Kind | Authoring interface and behavior |
| --- | --- |
| `ValidatingPolicy` | Select with `spec.matchConstraints`; evaluate CEL in `spec.validations` during admission and background scans. Can generate a Kubernetes `ValidatingAdmissionPolicy`. |
| `MutatingPolicy` | Return an apply-configuration patch from CEL in `spec.mutations`. Can mutate existing resources, run offline, or generate a Kubernetes `MutatingAdmissionPolicy` with automatic bindings. |
| `GeneratingPolicy` | Call `generator.Apply(namespace, resources)` in `spec.generate[].expression`; CEL loops can generate for multiple items or target namespaces. |
| `DeletingPolicy` | Set a cron schedule in `spec.schedule` and select existing resources with CEL conditions. Reuse `spec.variables` as `variables.<name>` in `spec.conditions`. |
| `ImageValidatingPolicy` | Extract image references from JSON, match with globs or CEL, and verify signatures and attestations. |
Creating or updating a `ValidatingPolicy` triggers a background scan in addition
to periodic scans. `MutatingPolicy` background scans can run on creation, update,
and a periodic schedule. Background `mutateExisting` checks `matchConditions`
and skips mutation when they fail. Configured mutation reinvocation is preserved.
`MutatingPolicy` resolves subresource triggers declared in `matchConstraints`;
the CLI passes the resolved subresource to CEL policy evaluation.
The `ValidatingPolicy` admission handler honors `failurePolicy: Ignore` for
runtime evaluation errors.
## Autogeneration, generation, and cleanup
`ValidatingPolicy` and `MutatingPolicy` can autogenerate Pod-controller rules.
CEL autogeneration can extend Pod rules to custom workload CRDs such as JobSet
by extracting embedded Pod templates. Pod-controller autogeneration can be
explicitly enabled or disabled in policy configuration.
The webhook covers workloads matched by autogenerated `NamespacedValidatingPolicy`
rules. Background scans discover workloads matched by autogenerated
`ImageValidatingPolicy` and `NamespacedImageValidatingPolicy` rules.
`GeneratingPolicy` synchronization carries through to `UpdateRequest` resources.
With synchronization enabled, generated resources are recreated after repeated
deletions. Synchronization handles custom resources and multiple triggers,
keeping downstream resources associated with the trigger that generated them.
`generateExisting` honors wildcard entries in `excludeResourceRules`.
Generation label protection is configurable; its webhook honors `failurePolicy: Ignore`.
Deletion policies process all pages when listing namespaced resources for cleanup.
Cleanup and deleting controllers honor configured `resourceFilters`.
## Policy exceptions
Identify policies by `kind` and `name` in `spec.policyRefs`; scope exceptions with
CEL in `spec.matchConditions`. Kyverno validates those CEL expressions.
When `exceptionNamespace` is configured, keep CEL exceptions in that namespace.
Generated Kubernetes `ValidatingAdmissionPolicy` resources honor the same
exception eligibility checks as Kyverno's runtime.
Use `spec.images` for image references or patterns and `exceptions.allowedImages`
in validation. A matching exception supplies `spec.allowedValues` as
`exceptions.allowedValues`. A matching exception defaults to `skip` in reports;
set `spec.reportResult: pass` to report it as a pass.
Exceptions can specify compensating controls and use the `resource` library for
Kubernetes object lookups. Pod-controller autogeneration rewrites Pod field paths
in exception match conditions to match embedded Pod templates; conditions
targeting controller metadata keep their original paths.
## CEL libraries and service authorization
The libraries provide Kubernetes object reads with `resource.Get` and
`resource.List`, HTTP calls with `http.Send` and `http.Post`, service account
parsing with `parseServiceAccount`, image parsing with `image`, and registry
metadata with `imagedata.Get`. The CEL reference retains their call examples.
Utilities include hashes, rounding, PEM certificate inspection, random strings,
object-list merging, JSON and YAML parsing, time functions, and gzip data handling.
Kyverno libraries can run in policy `spec.matchConditions`; for admission,
Kyverno evaluates these expressions after the request reaches its webhook.
The Authz Server returns allow or deny decisions for Envoy's External Authorization
filter and can serve standalone HTTP authorization. The Go SDK loads and compiles
policies, evaluates service requests, and returns structured authorization results
with optional metrics and hooks. API types and the SDK have dedicated repositories.
## Image verification
Dynamic Notary certificates can come from a ConfigMap through
`attestors[].notary.certs.expression`; use `attestors[].notary.certs.value` for a
literal certificate. Declare a named `spec.attestations` entry with
`referrer.type: sbom/cyclone-dx` for an SBOM published as an OCI referrer.
Image verification supports Cosign v3 signatures and correctly verifies signature
annotations with Cosign v2 and v3. Keyless signing supports `additionalExtensions`
to check additional signing certificate extensions. `ImageValidatingPolicy`
selects the newest matching attestation; verification fails closed for unverified
OCI referrers. Admission verification runs even when earlier processing supplied
verification metadata, and registry reads during verification are capped.
Wildcard image extraction skips scalar branches. Use `filter` on an
`imageExtractors` entry to restrict elements of a wildcard-matched array.
Set an image policy's `spec.webhookConfiguration.timeoutSeconds` for its webhook
timeout and `spec.failurePolicy: Ignore` to continue admission if evaluation fails.
## CLI evaluation and diagnostics
`ValidatingPolicy` can evaluate arbitrary JSON as `object`; `MutatingPolicy` in
JSON mode patches arbitrary JSON documents. `kyverno apply` and `kyverno test`
cover cleanup, HTTP and Envoy authorization policies, and `mutateExisting` rules.
Use `--exceptions-with-policies` to supply exceptions alongside policies.
Package CEL policies in OCI bundles. Use `kyverno oci validate` for CEL-aware
validation, `kyverno oci inspect` to examine a bundle, and `kyverno oci resolve`
to resolve its policy sets, which are named in the bundle descriptor.
The CLI resolves `NamespacedValidatingPolicy` match constraints and retains
`GeneratingPolicy` `skip` results in `kyverno test`. With `--cluster`, CEL engines
resolve Namespace objects from the live cluster. Use `--explain` to inspect
decisions; the admission controller can log decision traces when tracing is enabled.
Use `--output-file` or `--output-dir` for mutated manifest destinations:
```bash
kyverno apply mutate.yaml --resource deployment.yaml --output-file patched.yaml
```
`kyverno version` supports JSON and YAML output for scripts.
## Reporting, observability, and operations
The `reports.kyverno.io/disabled` label suppresses ephemeral reports and
PolicyReports independently of enforcement for `ClusterPolicy`, CEL policies,
`ValidatingAdmissionPolicy`, and `MutatingAdmissionPolicy`. Any label value works;
removing it resumes reporting. Use `--allowedResults` to select stored outcomes.
Execution metrics are Prometheus histograms. Use `execution_cause` to distinguish
`admission_request` from `background_scan`. The validating-policy `result` label
uses uppercase `PASS` and `FAIL`; failed evaluations per second over five minutes:
```promql
rate(kyverno_validating_policy_execution_duration_seconds_count{result="FAIL"}[5m])
```
Inspect CEL policy Events with `kubectl get events`. Set ConfigMap
`successEventActions` to select which success actions emit Events.
The `/metrics` endpoint supports TLS for HTTPS scraping, and the admission
controller supports memory-based scaling through a Horizontal Pod Autoscaler.
The Helm chart supports lifecycle hooks for all controllers; configure a cleanup
TTL for `UpdateRequest` resources to control retention.