Kyverno in Kubernetes: Policy as Code for the Whole Cluster

Kyverno in Kubernetes: Policy as Code for the Whole Cluster

A deep, plain-English guide to how Kyverno checks, changes, creates and cleans up Kubernetes resources, how it works inside the cluster, and how to run it safely in production.

Picture a huge apartment building with hundreds of families moving in and out every day. The building has a security desk at the front door. Every person who walks in is checked: Do you live here? Are you carrying anything dangerous? Is your name on the list? Without that desk, anyone could bring anything inside, and one careless person could cause trouble for everybody. A Kubernetes cluster is that building, every deployment is a family moving in, and Kyverno is the smart security desk that reads the building rules and applies them to everyone, every time, without getting tired.

This guide goes from the very first idea to advanced production topics. You do not need to know anything about policy engines before you start. Every new word is explained when it first appears, and each big idea comes with an everyday comparison. By the end, you will understand how Kyverno sits inside the Kubernetes request path, what its controllers do, how its policy types differ, how to roll it out without breaking teams, and how to keep it fast, safe and observable.

1Why Kubernetes Needs a Policy Engine

Kubernetes will happily run almost anything you give it, and that freedom is exactly the problem.

Kubernetes is a system that runs containers for you. You describe what you want in a text file, send it to the cluster, and Kubernetes makes it real. That description is called a manifest. Out of the box, Kubernetes checks that a manifest is shaped correctly. It does not check whether the manifest follows your company’s rules. If a developer asks for a container that runs with full administrator power on the machine, Kubernetes will say yes, because the request is valid, even though it is risky.

In a small team, people can review each other’s work and catch mistakes by eye. In a large company with dozens of teams and thousands of deployments each week, human review does not scale. People forget, people are in a hurry, and new joiners do not know every rule. You need something that enforces the rules automatically, at the exact moment a request arrives, before the risky thing is created. That something is a policy engine.

Simple Analogy

Think of a school with a dress code. You could ask every teacher to remember the code and check each student by eye, and some would forget. Or you could install a gate at the entrance with a clear checklist. The gate does not get tired, does not play favorites, and treats the first student of the morning exactly like the last one. A policy engine is the gate.

What kinds of rules do teams usually want?

Most organizations end up with a similar list. They want every workload to carry labels so cost and ownership can be tracked. They want containers to avoid running as the all-powerful root user. They want images to come only from trusted registries. They want resource limits so one greedy application cannot starve its neighbors. They want certain security settings switched on by default. And they want these rules to be written down in a form that can be reviewed, versioned and tested like any other code.

Need 1

Security

Stop privileged containers, host access and unsigned images before they ever start.

Need 2

Compliance

Prove to auditors that required controls are applied to every workload, not just most.

Need 3

Cost and Fairness

Require resource requests and limits so no single team can consume the whole cluster.

Need 4

Consistency

Make sure labels, annotations and defaults look the same across every team and namespace.

i
Key Idea

A policy engine turns rules that live in people’s heads or in wiki pages into rules that live inside the cluster and are enforced by machines.

2What Kyverno Is and Where It Came From

Kyverno is a policy engine built for Kubernetes, using Kubernetes’ own style of resources to describe rules.

The name Kyverno comes from a Greek word meaning “to govern”. It started in 2019, created by a company called Nirmata, and was given to the Cloud Native Computing Foundation, usually shortened to CNCF, in 2020. The CNCF is the neutral home for many famous cloud tools. Kyverno entered as a sandbox project, moved up to incubating in 2022, and reached the top maturity level, called graduated, in March 2026. Graduation means the project passed security reviews, has a healthy and diverse set of contributors, and is trusted in real production systems around the world.

What makes Kyverno different is how you write rules. In many older policy tools, you must learn a separate programming language just to describe a rule. Kyverno took a different path: policies are Kubernetes resources. They are stored in the cluster, listed with the same tools you already use, protected by the same access controls, and managed through the same pipelines as your other resources. If you already understand how Kubernetes describes a Deployment or a Service, the shape of a Kyverno policy will feel familiar.

Simple Analogy

Imagine two ways to write house rules. One way needs a special legal language that only lawyers read. The other way uses the same everyday notice-board format the whole neighborhood already knows. Kyverno chose the notice board. Anyone who can read a Kubernetes resource can read a Kyverno policy.

The four jobs Kyverno does

Kyverno does much more than say “no”. Over the years its abilities grew into a family of jobs, and each job has its own purpose.

Job 1

Validate

Check a resource against a rule and allow it, warn about it, or reject it.

Job 2

Mutate

Quietly change a resource on the way in, for example adding a missing default setting.

Job 3

Generate

Create new resources automatically when something happens, such as a new namespace appearing.

Job 4

Verify Images

Confirm that container images are signed and come from where you expect before they run.

There are also supporting jobs: cleaning up old resources on a schedule, reporting the results of every check, and letting you grant carefully controlled exceptions. You will meet all of them in this guide.

2019
Kyverno first created
2020
Donated to the CNCF
2026
Reached CNCF graduated status

Who uses it?

Public CNCF material lists large organizations such as Bloomberg, Coinbase, Deutsche Telekom, LinkedIn, Spotify, Vodafone and Wayfair among Kyverno’s users, which shows it is trusted far beyond hobby clusters.

3Admission Control: The Doorway Kyverno Guards

To understand Kyverno, you first need to understand the path every request takes through the Kubernetes API server.

Everything in Kubernetes goes through one front door called the API server. When you create a pod, update a deployment or delete a secret, you are sending a request to the API server. Before that request is saved into the cluster’s database, it passes through several stages. First comes authentication, which asks who you are. Then authorization, which asks whether you are allowed to do this. Then comes the stage Kyverno cares about: admission control.

Admission control is a set of checkpoints that look at the content of the request itself. There are two kinds. Mutating admission can change the request. Validating admission can only accept or reject it. Kubernetes runs all the mutating checkpoints first, then checks the shape of the final object, and then runs all the validating checkpoints. Only if everything agrees does the object get saved.

flowchart LR
  A["Client sends request"] --> B["Authentication: who are you?"]
  B --> C["Authorization: are you allowed?"]
  C --> D["Mutating admission"]
  D --> E["Schema validation"]
  E --> F["Validating admission"]
  F --> G["Saved in etcd"]
        
FIG 1 — The path of a request through the Kubernetes API server

Webhooks: how outside programs join the checkpoint

Kubernetes lets outside programs join the admission stage using something called a webhook. A webhook is simply a web address that Kubernetes calls with the request details, asking “what do you think?”. The outside program answers yes or no, and for mutating checkpoints it can also say “yes, but change these things first”. Kyverno registers itself as both a mutating and a validating webhook. That is how it gets a chance to look at every request that matches its policies.

Simple Analogy

A webhook is like the airport security agent who is not employed by the airline but is given a desk right at the gate. The airline, which is Kubernetes, pauses each passenger and asks the agent for a decision. The agent checks the rules and waves the passenger through or turns them back.

!
Common Misconception

Admission control only sees requests that create, update or delete things. It does not look at resources that already exist and are sitting quietly. That is why Kyverno also has a background scanning feature, which you will learn about in a later chapter.

Why the failure behavior matters

Because the API server waits for the webhook’s answer, the webhook becomes part of the critical path. If the webhook is slow, requests become slow. If the webhook is unreachable, Kubernetes must decide what to do. Each webhook has a failure setting: fail closed means requests are rejected when the webhook cannot answer, and fail open means requests are allowed through. This single setting is one of the most important design decisions in a policy deployment, and we will return to it when we talk about high availability.

“A policy engine on the admission path is not just a rulebook; it is a dependency of every deployment in the cluster.”

4Kyverno Architecture and Its Controllers

Kyverno is not one big program. It is a small team of specialized controllers, each doing one kind of work.

When you install Kyverno, you get several deployments running in the cluster, usually in their own namespace. Splitting the work this way is a deliberate design choice. It lets each part scale on its own, fail on its own, and be given only the permissions it truly needs. A controller, in Kubernetes language, is a program that watches the cluster and keeps working until reality matches what is wanted.

flowchart TD
  API["Kubernetes API Server"]
  ADM["Admission Controller"]
  BG["Background Controller"]
  REP["Reports Controller"]
  CLN["Cleanup Controller"]
  POL["Policy resources"]
  RES["PolicyReport resources"]
  API -- "webhook calls" --> ADM
  POL --> ADM
  POL --> BG
  BG -- "generate and mutate existing" --> API
  ADM -- "ephemeral results" --> REP
  BG -- "scan results" --> REP
  REP --> RES
  CLN -- "delete on schedule" --> API
        
FIG 2 — The main Kyverno controllers and how they relate
Controller 1

Admission Controller

Receives webhook calls from the API server, evaluates policies in real time, and answers allow, deny or mutate. This is the one on the hot path.

Controller 2

Background Controller

Handles work that does not happen inside a live request, such as generating resources and mutating resources that already exist.

Controller 3

Reports Controller

Collects the results of checks and turns them into readable report resources you can query.

Controller 4

Cleanup Controller

Deletes resources that match a rule, usually on a schedule, and also hosts its own webhook service for related features.

Simple Analogy

Think of a restaurant. The admission controller is the host at the door, deciding quickly who may enter. The background controller is the kitchen staff, working on longer jobs behind the scenes. The reports controller is the person who writes the daily log. The cleanup controller is the night crew that clears old tables. One person doing all four jobs would be slow and would make mistakes.

Why separate permissions are a feature

Each controller runs with its own service account and its own set of permissions. The admission controller must be able to read many kinds of resources to evaluate rules. The cleanup controller needs permission to delete only what your cleanup rules target. If one component were compromised, the damage would be limited to what that component was allowed to do. This is the principle of least privilege applied to the policy engine itself.

i
Operational Tip

Scale the admission controller for traffic and availability, because it sits on the request path. The other controllers can be sized more modestly unless you have heavy background scanning or many generated resources.

5Policy Types: Legacy Policies and the CEL Generation

Kyverno has recently gone through its biggest change: a new family of policy types built on the Common Expression Language.

For years, Kyverno’s rules lived in two resource types: ClusterPolicy, which applies cluster-wide, and Policy, which applies inside a single namespace. Both used Kyverno’s own rule engine, with its own pattern-matching syntax and its own way of querying data. It worked well and many organizations built large policy libraries on it.

Meanwhile, Kubernetes itself introduced a built-in way to write validation rules using the Common Expression Language, shortened to CEL. CEL is a small, fast language for writing safe expressions such as “this value must be less than that value”. Kubernetes chose CEL for its native admission policies because it is quick to evaluate and cannot run wild loops or reach outside the sandbox. Kyverno decided to align with this direction rather than compete with it.

According to the project’s own release announcements, version 1.17, released in February 2026, promoted the CEL-based policy types to stable status, called v1 or generally available. At the same time, the older ClusterPolicy approach was marked deprecated, with removal planned for a later release in the second half of 2026. The CEL-based family includes policy types dedicated to each job.

Policy TypeMain JobTypical Example
ValidatingPolicyCheck and allow, warn or denyBlock privileged containers
NamespacedValidatingPolicySame as above, limited to one namespaceA team’s own local rules
MutatingPolicyChange resources on the way in or afterAdd default security settings
GeneratingPolicyCreate companion resourcesDefault network rules for new namespaces
ImageValidatingPolicyVerify image signatures and attestationsOnly run signed images
DeletingPolicyRemove resources by condition and scheduleDelete expired temporary pods
!
Check Your Version

Kyverno moves quickly and its release dates and removal timelines can shift. Always confirm the current status in the official release notes and migration guide before planning work. The ideas in this guide stay valid; the exact version numbers are the part to double-check.

Why the change helps you

The CEL-based types give you a more focused structure. Instead of one giant policy shape that can do everything, each type has fields that suit its job. They also benefit from CEL’s speed and from the fact that Kubernetes’ own native policies use the same language, so skills transfer between the two worlds. Kyverno adds extra function libraries on top of standard CEL so that it can still do things the native engine cannot, such as looking at other resources in the cluster or checking image signatures.

Simple Analogy

The old way was a Swiss Army knife: one tool, many blades, a bit crowded. The new way is a well-organized toolbox with a screwdriver, a hammer and a saw, each shaped for its task. You can still do everything, but each tool is easier to hold.

6Validation Policies in Depth

Validation is the most common use of Kyverno: read the resource, test a condition, and decide what happens next.

A validation policy has three ingredients. The first is a match: which kinds of resources and which operations should this policy look at? The second is the condition, written as one or more expressions that must be true for the resource to be acceptable. The third is the action: what should happen when the condition is false? Kubernetes-style validation actions give you three choices, and picking among them is where much of the real-world skill lies.

1

Audit

Let the request through, but record the violation in a report. Perfect for learning what would break before you turn enforcement on.

2

Warn

Let the request through, but show the person a warning message right in their terminal. Teaches people while they work.

3

Deny

Reject the request and explain why. Use it when the rule is well understood and teams have had time to prepare.

Writing good messages

The message attached to a rule is shown to the person whose request was rejected. A poor message such as “validation failed” makes people angry and sends them to your support channel. A good message says what rule was broken, why the rule exists, and what to change. Treat policy messages as part of your product. The people reading them are your customers.

Simple Analogy

A road sign that only says “No” is frustrating. A sign that says “No trucks over 3 tons, bridge is weak, use Highway 9” helps the driver and prevents repeat mistakes. Your policy messages should be the second kind of sign.

Variables and reuse

Real rules often need the same piece of data several times, such as the list of containers in a pod, including the init containers and the temporary ones. CEL-based policies let you define named variables once and reuse them in several expressions. This keeps rules short, readable and easier to test. It also means a mistake in how you collect the container list is fixed in one place.

Matching the right requests

Policies can match by resource kind, by operation such as create or update, by namespace, by labels, and by who is making the request. Narrow matching is a performance feature as well as a correctness feature. A policy that matches only pods costs nothing for a request about a config map. A policy that matches everything makes the engine work on every single request.

Example: Require ownership labels

A platform team wants every deployment to say which team owns it. A validation policy checks for the owner label. In audit mode for two weeks it shows which teams are missing the label. In deny mode afterwards it prevents new unlabeled deployments.

Example: Block host access

A security team forbids pods from sharing the machine’s network or process space. The policy checks the pod settings that control host sharing and denies any pod that turns them on.

Example: Require resource limits

To keep the cluster fair, a policy requires every container to declare how much memory and processing power it may use. Without limits, a single bug can eat the whole machine.

i
Pod Security Standards

Kubernetes defines well-known baseline and restricted security levels for pods. Kyverno’s public policy library includes ready-made policies that implement these levels, so you rarely need to invent the basics from scratch.

7Mutation Policies in Depth

Mutation lets Kyverno fix things for people instead of just telling them off.

Rejecting a request is sometimes the wrong tool. Imagine a hundred teams, and a new company rule says every container must drop a dangerous capability by default. If you only validate, every team gets an error and must edit its manifests. If you mutate, Kyverno adds the safe setting automatically and nobody is interrupted. Mutation is how platform teams provide safe defaults without creating friction.

Mutation happens during the mutating stage of admission, before the object is stored. Kyverno receives the request, applies the changes, and sends back a description of the changes. The API server applies them and then moves on to the validation stage. This ordering is important: because validation runs after mutation, your validation rules see the final, mutated object.

Simple Analogy

A hotel front desk that notices your booking has no check-out time does not send you away. It simply writes the standard check-out time on your booking. You are happy, the hotel is happy, and the rule is satisfied.

Mutating existing resources

Normal mutation only affects resources entering the cluster. Kyverno can also change resources that already exist, using the background controller. For instance, when a particular config map changes, you can update all the deployments that depend on it. This is a powerful pattern and also a dangerous one, because it changes live objects without a human in the loop. Use it with narrow matching and careful testing.

Common mutation use cases

Use 1

Safe defaults

Set secure pod settings, such as disallowing privilege escalation, when the author did not choose.

Use 2

Labels and annotations

Add standard metadata for cost tracking, ownership and monitoring.

Use 3

Image registry rewrite

Point images at an internal mirror so clusters do not depend on the public internet.

Use 4

Scheduling hints

Add tolerations or node selectors so workloads land on the right group of machines.

!
Watch Out

Mutation can surprise people. If a developer deploys one thing and the cluster runs something slightly different, debugging gets confusing. Always document what your mutation policies add, and prefer mutating for harmless defaults rather than for changes that alter how an application behaves.

ANTI-PATTERN-01 Avoid
Problem

Several mutation policies each change the same field in different ways, and nobody knows which one wins.

Why It’s Harmful

The final result depends on the order in which policies run, which is hard to predict. Teams see behavior that looks random and lose trust in the platform.

Correct Approach

Give each field one owner. Keep mutation policies small and focused, and review them together so they never fight over the same setting.

8Generation Policies and Resource Lifecycle

Generation makes Kyverno a builder: when one thing appears, it creates the supporting things automatically.

Every time a team asks for a new namespace, a platform engineer used to do the same chores by hand. Add a default network rule. Add a quota so the team cannot use unlimited resources. Add a role binding so the team can work in its space. Add a standard config map. These are repetitive, easy to forget, and easy to get slightly wrong. A generation policy watches for a trigger, such as a new namespace, and creates all the companion resources at once.

Simple Analogy

When a new student enrolls at a school, the office automatically prints a locker assignment, a library card and a timetable. Nobody has to remember each item, because enrollment triggers the whole bundle.

sequenceDiagram
  participant Dev as Developer
  participant API as API Server
  participant BG as Background Controller
  Dev->>API: Create namespace
  API-->>Dev: Namespace saved
  BG->>API: Watches for new namespaces
  BG->>API: Create default network rule
  BG->>API: Create resource quota
  BG->>API: Create role binding
        
FIG 3 — A generation policy reacting to a new namespace

Keeping generated resources in sync

Generation has a clever extra feature: synchronization. When synchronization is on, Kyverno treats the policy as the source of truth. If someone edits or deletes a generated resource by hand, Kyverno puts it back the way the policy describes. If you change the policy, the generated resources follow. When the trigger resource is deleted, the generated ones can be cleaned up with it. This gives you a lifecycle that matches the trigger, rather than a pile of orphaned objects.

Cloning versus creating from scratch

A generation policy can build a resource from a description inside the policy, or it can clone an existing resource from another namespace. Cloning is useful when the source of truth is a carefully maintained object, such as a shared registry credential that every namespace needs. You update the original once, and every clone follows.

Advantages

  • New namespaces are ready and safe from the first second
  • Platform chores become consistent and repeatable
  • Drift is corrected automatically when synchronization is on
  • Teams get self-service without waiting for tickets

Disadvantages / Trade-offs

  • Synchronization can overwrite changes someone made on purpose
  • The background controller needs permission to create many resource kinds
  • A mistake in the policy is copied into every new namespace
i
Permission Reminder

Kyverno can only generate what its own service account is allowed to create. If a generation policy seems to do nothing, check that the background controller has the access it needs for that resource kind.

9Image Verification and the Software Supply Chain

A container image is a program someone else built. Kyverno helps you confirm who built it and that nobody tampered with it.

Every pod runs an image pulled from a registry. If an attacker slips a malicious image into the registry, or tricks a developer into using a lookalike name, your cluster will happily run it. The set of steps that take code from a developer’s laptop to a running container is called the software supply chain, and attacking it has become a favorite technique of serious adversaries. Verifying images at admission time closes one of the most important doors.

Simple Analogy

When you buy medicine, you look for the sealed cap and the pharmacy’s stamp. A broken seal means somebody may have opened it. Image signatures are the sealed cap: they prove the image is exactly what the trusted builder produced.

Signatures and attestations

A signature is a cryptographic proof, attached to an image, that a particular trusted identity approved it. Tools in the Sigstore ecosystem, with Cosign being the best known, make signing practical. An attestation goes one step further. It is a signed statement about the image, such as “this image was built by our pipeline”, “this image passed vulnerability scanning on this date”, or “here is the list of ingredients inside it”, which is called a software bill of materials. Kyverno can check both.

Kyverno’s image verification policy type reaches out to the registry, fetches the signature and attestations, checks them against the keys or identities you trust, and decides whether to allow the pod. It can also rewrite the image reference from a movable tag to an exact fixed digest, so that what was verified is exactly what runs. This closes a subtle gap: a tag like “latest” can be moved to a different image after you checked it, but a digest cannot.

1

Build and sign

The pipeline builds the image and signs it, recording attestations such as scan results.

2

Push to the registry

The image and its signature material are stored together in the registry.

3

Request arrives

A developer deploys a pod. The API server calls Kyverno at admission time.

4

Verify and decide

Kyverno checks the signature and attestations against trusted identities, then allows or denies the pod.

!
Availability Trade-off

Verification needs the registry to be reachable. Plan for registry slowness and outages, caching of results, and credentials for private registries. A verification policy that depends on a flaky network can slow down every deployment.

Example: Only our pipeline may ship to production

A company requires that every image running in the production namespaces carries a signature from its official build pipeline. Developers can still run anything in a sandbox namespace, but production refuses unsigned images.

Example: No known-bad images

The pipeline attaches a scan result attestation. A policy denies pods whose attestation is missing or older than a chosen number of days, forcing images to be rescanned regularly.

10Cleanup and Time-Based Governance

Clusters collect clutter. Kyverno can sweep it away on a schedule, following rules you wrote down.

Anyone who has run a shared cluster knows the mess that builds up. Test pods that nobody deleted. Completed jobs that stay for months. Temporary namespaces created for a demo and forgotten. Each leftover costs money and adds noise. Kyverno’s cleanup features let you describe which resources are eligible for deletion and when to look for them. The cleanup controller then wakes up on schedule, finds matching resources, and deletes them.

Simple Analogy

A shared office fridge has a rule: anything left over the weekend gets thrown out on Monday morning. Nobody has to nag colleagues. The cleaning crew follows the written rule at the same time every week.

Two ways to clean up

The first way is a scheduled rule: on a repeating timetable, find every resource that matches certain conditions and delete it. The second way is a time-to-live label. A resource is stamped with a label saying how long it may live, and Kyverno removes it when that time is up. This is wonderful for short-lived environments, because the person creating something can decide its lifetime right at creation, and forgetting to clean up no longer costs money.

Pattern 1

Expire preview environments

Every namespace made for a pull request gets a short lifetime and disappears on its own.

Pattern 2

Remove finished jobs

Completed batch jobs older than a set age are removed to keep the cluster tidy.

Pattern 3

Delete unhealthy leftovers

Pods stuck in a failed state for too long are removed so they stop confusing dashboards.

Pattern 4

Expire temporary access

Short-term elevated permissions are deleted when their time window ends.

!
Deletion Is Permanent

A cleanup rule that matches too much can delete real workloads. Test the match conditions in a safe environment, start with narrow selectors, and give the cleanup controller permission only for the kinds it needs.

11Context: Reading Data Beyond the Request

Some rules cannot be decided by looking at the incoming object alone. They need extra facts from the cluster or from the outside world.

Imagine a rule that says “a service may only use a hostname that no other service already uses”. The incoming object cannot answer that. Kyverno must also look at other services in the cluster. Or imagine a rule that depends on a list of approved registries kept in a config map that the security team updates. Kyverno needs to read that config map at evaluation time. Collecting these outside facts is called bringing in context.

Simple Analogy

A bouncer at a club can check your age from your ID, which is the incoming object. But to check whether you are on tonight’s guest list, the bouncer must look at a separate sheet of paper. That sheet is the context.

Sources of context

Source 1

Config maps

Lists maintained by humans, such as approved registries or allowed team names.

Source 2

Other resources in the cluster

Ask the Kubernetes API about existing objects, for example to detect duplicates or count things.

Source 3

Image registry data

Read image details such as digests, signatures and metadata.

Source 4

External services

Newer releases include libraries that let policies call out to web services, which opens powerful options and serious risks.

!
Cost of Context

Every outside lookup adds time to the admission request. A policy that makes a slow network call on every pod creation can slow the whole cluster down. Cache what you can, keep lookups narrow, and never call a service that might hang without a strict time limit.

ANTI-PATTERN-02 Avoid
Problem

A policy calls a slow external service on every request, with no limit on waiting time.

Why It’s Harmful

The API server waits for Kyverno, and Kyverno waits for the service. When the service slows down, every deployment in the cluster slows down or fails.

Correct Approach

Prefer data kept inside the cluster, cache lookups, set tight time limits, and decide in advance what should happen if the lookup fails.

12Matching, Scoping and Exclusions

A policy is only as good as its aim. Matching decides what it sees, and exclusions decide what it must leave alone.

Every Kyverno policy begins with a statement of what it applies to. You can match by kind, such as pods or deployments. You can match by operation: create, update, delete or connect. You can match by namespace, by namespace labels, by object labels, and by details of the user making the request. Matching well matters for two reasons. It keeps the rule from hitting things it was never meant for, and it keeps the engine fast, because irrelevant requests are skipped quickly.

Why some namespaces are special

Every cluster has system namespaces holding the parts that make Kubernetes work. If a policy blocks something those components need, the cluster can stop healing itself. Kyverno ships with resource filters and sensible defaults that skip some system areas, and good policy authors also exclude system namespaces explicitly. Kyverno’s own namespace deserves special care: if a rule prevents Kyverno’s own pods from starting, you may lock yourself out of fixing the problem.

Simple Analogy

A building rule that says “no loud noise after 9 pm” should not apply to the fire alarm. Exclusions are how you protect the fire alarm. Without them, a well-meaning rule can silence something essential.

Scope by tier

Many organizations use layers of scope. Cluster-wide policies, owned by the platform and security teams, cover rules that never change, such as banning privileged containers. Namespaced policies, owned by each application team, cover local rules, such as naming conventions for that team’s own resources. This split lets teams govern themselves without being able to weaken the global rules.

ScopeOwned ByBest For
Cluster-widePlatform and securityNon-negotiable safety rules
Namespace-levelApplication teamsLocal conventions and team-specific checks
Exception-basedPlatform, with approvalRare, documented departures from a rule
i
Rule of Thumb

Write the narrowest match that still catches the problem. Broad matches are the number one cause of both surprising rejections and wasted processing time.

13Policy Reports and Background Scans

Blocking new problems is half the story. You also need to see the old problems that were already there.

Admission control only sees requests as they happen. A deployment created last year, before a rule existed, never faced that rule. Kyverno therefore runs background scans, which periodically re-check existing resources against your policies. The results, together with the results from live admission checks in audit mode, are written into report resources that you can read like any other Kubernetes object.

The reports follow a common format shared across the Kubernetes policy ecosystem. Each report lists resources and, for each one, whether it passed, failed, produced a warning, was skipped, or caused an error. Namespaced resources go into namespaced reports. Cluster-level resources go into cluster reports. Because reports are normal resources, you can query them with standard tools, display them in dashboards, or feed them to alerting systems.

flowchart LR
  A["Live admission check"] --> R["Reports Controller"]
  B["Background scan"] --> R
  R --> N["Namespaced PolicyReport"]
  R --> C["ClusterPolicyReport"]
  N --> D["Dashboards and alerts"]
  C --> D
        
FIG 4 — How check results become reports
Simple Analogy

The gate guard checks everyone entering today. But the school also does a yearly inspection of every classroom that was built long ago. Admission checks are the gate guard. Background scans are the annual inspection. Reports are the inspector’s written results.

Seeing reports in a friendlier way

Raw report resources are accurate but not pretty. The Kyverno ecosystem includes a companion project that turns reports into dashboards, sends alerts to chat tools and ticket systems, and exposes metrics for monitoring. Many teams treat it as the human face of their policy program.

Pass
Resource follows the rule
Fail
Resource breaks the rule
Warn
Rule broken, but only a warning
i
Use Reports as Your Roadmap

Before turning on any new deny rule, read the reports from audit mode. They tell you exactly which teams and which resources would be affected, so you can talk to them first.

14Policy Exceptions and the Governance Workflow

Rules without any way to bend them will eventually be worked around. Exceptions let you bend them safely.

No rule fits every situation. A legacy monitoring agent may truly need host access. A migration tool may need to run as the root user for a week. If your only options are “follow the rule” or “delete the rule”, people will pressure you to delete it, and then nobody is protected. Kyverno offers a dedicated exception resource that says, in writing, that a specific workload is excused from a specific rule.

Simple Analogy

A library says no food is allowed. But a person with a medical need can get a signed permission slip from the librarian. The slip names the person, the reason and the rule it overrides. The rule stays strong for everyone else.

What a good exception process looks like

1

Request

The team asks for an exception in version control, explaining the need and the planned end date.

2

Review

Security and platform owners review the risk and agree on the narrowest possible scope.

3

Apply

The exception resource is merged and applied. It names exact policies, rules and resources.

4

Expire and revisit

On the end date the exception is removed or renewed after another review. Nothing stays forever by accident.

!
Control Who Can Create Exceptions

If any developer can create an exception for any rule, the rule protects nothing. Restrict exception creation with access controls, and consider limiting which namespaces may host exceptions at all.

15Testing Policies Before They Reach the Cluster

A policy is code, and code that can reject every deployment in your company deserves serious testing.

Policies are powerful because they affect everything. That also makes mistakes costly. A policy with a typo in its condition might reject every pod, including the ones needed to repair the problem. Mature teams therefore test policies the same way they test software, in layers, and well before production.

Layer 1

Command-line checks

Kyverno has a command-line tool that applies policies to sample resource files without any cluster, and a test mode that compares real results against expected results.

Layer 2

Cluster-based tests

A declarative testing tool called Chainsaw runs end-to-end scenarios in a real test cluster: apply the policy, apply a resource, assert the outcome.

Layer 3

Audit in a staging cluster

Run the policy in audit mode against realistic workloads and read the reports before promoting it.

Layer 4

Gradual production rollout

Introduce the policy in audit mode in production, then warn, then deny, one environment at a time.

Simple Analogy

Before a new traffic rule is announced to a whole city, planners first try it at one intersection, watch the results, and fix problems. Policy testing is that single intersection, repeated in safe steps.

What to test

Good test suites include both good and bad examples. A pass case proves a correct resource is allowed. A fail case proves a bad resource is blocked. Edge cases matter most: containers with unusual names, init containers, resources missing optional fields, and updates as well as creates. Teams that skip edge cases often find them in production, at the worst time.

i
Put Tests in the Pipeline

Run policy tests automatically on every change to a policy. The same checks can also run against application manifests in the developer’s pipeline, so developers learn about violations before they ever reach the cluster.

16Rollout Strategy: From Audit to Enforce with GitOps

The technical part of Kyverno is easy to install. The human part, getting teams to accept it, is where projects succeed or fail.

The most common failure story goes like this. A security team installs Kyverno, switches on a pile of deny rules on a Friday, and by Monday dozens of teams cannot deploy. Trust collapses, rules are removed, and the project is called a failure. A careful rollout avoids this by moving through clear stages and communicating at each step.

flowchart LR
  A["Write policy in Git"] --> B["Test with CLI and Chainsaw"]
  B --> C["Audit in staging"]
  C --> D["Audit in production"]
  D --> E["Warn developers"]
  E --> F["Enforce with deny"]
  F --> G["Review and improve"]
  G --> A
        
FIG 5 — A safe path from a new idea to an enforced rule

Policies as code in Git

Store every policy in version control, review changes through pull requests, and let a GitOps tool apply them to clusters. This gives you a history of who changed which rule and why, an easy way to roll back, and the same review culture you already use for application code. It also prevents the dangerous habit of editing policies directly in a live cluster.

Simple Analogy

Changing school rules should go through the school board with minutes written down, not through one teacher scribbling a new rule on the whiteboard. Git is the minutes book.

Advantages

  • Teams see problems early and fix them calmly
  • Trust in the platform grows with every smooth rollout
  • Every rule has an owner, a history and a reason
  • Rollback is a single revert

Disadvantages / Trade-offs

  • Rollout takes weeks rather than hours
  • Long audit periods can feel like nothing is happening
  • Requires steady communication with every team
i
Communicate Early

Publish the policy list, the schedule for moving from audit to deny, and where to ask for help. Surprises create enemies; announcements create allies.

17High Availability, Performance and Scaling

Because Kyverno sits on the request path, its reliability becomes the cluster’s reliability.

If the admission controller goes down while the webhook is set to fail closed, nobody can create or update the resources covered by the webhook. If it is set to fail open, policies silently stop protecting you during the outage. Neither outcome is comfortable, so production setups invest in keeping the admission controller healthy.

Run more than one copy

The standard advice is to run several replicas of the admission controller, spread across different machines and failure zones, with disruption budgets so that routine maintenance never takes all of them down at once. Kyverno’s documentation recommends multiple replicas for production, commonly three. Controllers that do background work use leader election, which means only one copy is the active worker at a time while the others wait to take over.

Simple Analogy

A hospital never has just one doctor on night duty. If that doctor falls ill, patients wait. Several doctors, on different schedules, keep the service running even when someone is away.

Fail closed or fail open?

SettingWhen Webhook Is UnreachableBest For
Fail closedRequests are rejectedCritical security rules where a gap is unacceptable
Fail openRequests are allowed throughConvenience rules where availability matters more

Keeping it fast

Tune 1

Narrow matching

Policies that match fewer kinds and operations mean fewer webhook calls and less work.

Tune 2

Right-size resources

Give the admission controller enough memory and processing power for your request volume.

Tune 3

Limit external lookups

Every network call adds delay. Cache, filter and time-limit them.

Tune 4

Prefer CEL policies

The project positions its CEL-based engine as the faster, forward-looking path.

!
Recovery Plan

Decide ahead of time how you would recover if a bad policy blocked everything, including Kyverno itself. Know which webhook configurations can be removed or relaxed, who is allowed to do it, and where the instructions are written. Practice it once before you need it.

18Securing Kyverno Itself

The guard at the door must also be guarded. Kyverno has wide read access and can change resources, so it is a valuable target.

To do its job, Kyverno needs permissions across many parts of the cluster. That makes it attractive to an attacker. If someone could change your policies, they could switch off protections or even use mutation and generation to plant dangerous resources. Securing Kyverno means securing who can touch policies, who can touch Kyverno’s own deployments, and what each controller is allowed to do.

Guard 1

Protect policy resources

Only a small trusted group should be able to create, change or delete policies and exceptions.

Guard 2

Least privilege

Grant each controller only the access it needs. Review extra permissions added for generation and cleanup.

Guard 3

Secure the namespace

Limit who can exec into, edit or delete Kyverno’s own pods and webhook configurations.

Guard 4

Stay patched

Policy engines receive security advisories like any software. Follow the release notes and upgrade on a regular rhythm.

Simple Analogy

The master key to a building is kept in a locked box, with a log of who opened it. Kyverno’s policies and permissions are the master key. They deserve the locked box and the log.

Release support and upgrades

The project has announced a support model where the current release and the one before it receive patches. In practical terms, that means you should not fall many versions behind. Plan regular upgrades, read the upgrade notes for removed or deprecated features, and test the upgrade in a non-production cluster first.

i
Use Policies to Protect Policies

A neat trick is to write a policy that restricts who may change other policies and Kyverno’s own configuration. The engine can help guard itself, as long as you also keep a recovery path outside of it.

19Observability: Metrics, Logs and Traces

You cannot manage what you cannot see. Good observability tells you whether policies are healthy, fast and effective.

Observability means being able to ask questions about a running system and get answers. For Kyverno, the questions fall into three groups: Is it healthy and fast? Are policies doing what we expect? And when a request is rejected, why exactly? Three kinds of signals help: metrics, logs and traces.

Signal 1

Metrics

Numbers over time, such as how many requests were checked, how many were denied and how long evaluation took. Ideal for dashboards and alerts.

Signal 2

Logs

Detailed text records of what each controller did. Essential for investigating a specific rejection or a failed generation.

Signal 3

Traces

The path of one request through several components, showing where time was spent. Useful for hunting slow policies.

Signal 4

Reports and events

Policy reports and Kubernetes events show outcomes in terms people understand: which resource failed which rule.

Simple Analogy

A car dashboard shows speed and fuel, which are metrics. The mechanic’s notebook records what was fixed, which is the log. A trace is like a map of the whole trip with the traffic jams marked. You want all three to understand a long journey.

What to watch

1

Admission latency

How long webhook calls take. Rising latency warns of heavy policies, slow lookups or under-sized pods.

2

Rejection rate

A sudden jump usually means a new rule just landed or a team has a broken pipeline.

3

Failure and error counts

Errors during evaluation mean a policy itself is broken, which is more serious than a normal denial.

4

Violations over time

A healthy program shows the number of failing resources going down as teams fix things.

i
Alert on the Engine, Not Only the Rules

Create alerts for the health of the admission controller itself: unavailable replicas, webhook timeouts and rising error rates. A silent policy engine is more dangerous than a loud one.

20Kyverno, Native Admission Policies and Gatekeeper

Kyverno is not the only way to enforce rules. Knowing the neighbors helps you choose the right tool for each job.

Kubernetes now includes its own built-in validation feature, called ValidatingAdmissionPolicy, which uses CEL and runs inside the API server with no webhook at all. It is fast and has no extra component to maintain. It is also intentionally focused: it checks the incoming object and allows or rejects it. Another popular tool is OPA Gatekeeper, a policy engine built on the Open Policy Agent project, where rules are written in a separate language called Rego. Both Kyverno and Gatekeeper are CNCF graduated projects.

FeatureKyvernoNative Admission PolicyGatekeeper
Rule languageCEL-based types, plus legacy rule engineCELRego
Runs asWebhook-based controllersBuilt into the API serverWebhook-based controller
ValidateYesYesYes
MutateYes, including existing resourcesLimited, newer capabilityYes, through separate resources
Generate resourcesYesNoNo
Verify image signaturesYesNoNot a core feature
Cleanup resourcesYesNoNo
Extra component to runYesNoYes
Simple Analogy

A native admission policy is the lock built into the door by the manufacturer: simple, fast, always there. Kyverno is a full security team with a lock, a camera, a cleaning crew and an assistant who prepares the room. If all you need is a lock, the built-in one is enough. If you need the whole team, you hire one.

How to choose

Choose native policies when

Your needs are simple validation rules, you want zero extra moving parts, and you can live with the features Kubernetes provides directly.

Choose Kyverno when

You need mutation, generation, image verification, cleanup, rich reporting, exceptions, or one consistent tool that covers all of these, and your team prefers Kubernetes-style resources over a new language.

Choose Gatekeeper when

Your organization already has deep Rego expertise and shared policy libraries across many systems beyond Kubernetes.

i
They Can Work Together

CNCF commentary describes Kyverno and native policies as complementary. Because Kyverno now speaks CEL too, it can fit alongside native policies rather than replace them.

21Migrating from ClusterPolicy to CEL Policies

If you already run Kyverno, the most important project on your list for the coming months is likely this migration.

The legacy ClusterPolicy and Policy resources have been marked deprecated, and the project has published a migration guide that maps old fields to their new equivalents. Removal is planned for a release later in 2026. Because dates can move, check the official announcements, but treat the direction as settled: the CEL-based types are the future, and new work should start there.

1

Take inventory

List every legacy policy, who owns it, what it does, and how often it triggers. Retire any that nobody needs.

2

Sort by job

Group policies into validation, mutation, generation, image verification and cleanup, because each now has its own new type.

3

Convert and test side by side

Write the new version, run both in audit mode, and compare the reports. They should agree on every resource.

4

Switch over carefully

Move the new policy to its real action and remove the old one, one policy family at a time.

5

Update tests and pipelines

Make sure the command-line tests, pipeline checks and documentation point to the new policies.

Simple Analogy

Moving house is easier if you pack one room at a time and keep living in the old place until the new one is ready. You do not throw everything in a truck on a single night. Policy migration works the same way.

!
Do Not Wait for the Deadline

Leaving migration to the last month means doing it under pressure, with less time to compare results. Starting early gives you a calm, boring migration, which is the best kind.

ANTI-PATTERN-03 Avoid
Problem

Converting every policy mechanically, one for one, without questioning whether the policy is still useful.

Why It’s Harmful

You carry old clutter into the new system and double the work. Policies that no longer match your needs keep blocking people for no good reason.

Correct Approach

Use migration as a spring cleaning. Review each policy, retire what is obsolete, and merge duplicates before converting what remains.

22Multi-Tenancy and Platform Engineering Patterns

When many teams share one cluster, Kyverno becomes the tool that gives each team freedom inside safe walls.

Multi-tenancy means several independent groups, called tenants, share the same infrastructure. Each tenant wants to move fast. The platform team wants everyone to stay safe and fair. Kyverno helps by creating the walls automatically when a tenant is onboarded and by enforcing the rules that keep tenants from harming each other.

flowchart TD
  T["New team onboarded"] --> N["Namespace created"]
  N --> G["Generation policy adds quota, network rules and access"]
  G --> M["Mutation policy adds labels and safe defaults"]
  M --> V["Validation policies check every deployment"]
  V --> I["Image policy verifies signatures"]
  I --> R["Reports show compliance to the platform team"]
        
FIG 6 — A tenant’s journey through the policy layers

The paved road idea

Platform teams often talk about a paved road: the easy, well-lit path that most teams should follow. Kyverno supports this by making the safe way the default way. Mutation fills in sensible settings so teams do not have to know every detail. Validation catches the rare case that falls off the road. Generation builds the road for every new neighborhood. Teams that stay on the road have almost no friction, while teams that need something different can request an exception.

Simple Analogy

A city builds sidewalks, crosswalks and street lights for every new neighborhood. People can still walk across the grass, but most use the sidewalk because it is easy and safe. Good policy design makes the safe choice the easy choice.

Pattern: Per-tenant quotas

Generation creates a quota and limit settings in each tenant namespace, sized by a label such as small, medium or large. Validation prevents tenants from deleting their own quota.

Pattern: Network isolation by default

Each new namespace gets a default network rule that denies traffic from other tenants. Teams then open only the connections they need.

Pattern: Cost allocation labels

Validation requires cost-center and owner labels, and mutation copies them from the namespace onto workloads so billing reports are always complete.

23Design Patterns and Anti-Patterns

Experienced teams keep running into the same shapes of good and bad design. Learn them early.

Patterns that work

Pattern 1

Audit first, enforce later

Every new rule begins as a quiet observer and graduates to a blocker only after the data looks clean.

Pattern 2

One rule, one purpose

Small policies are easier to understand, test, own and retire than giant ones that do many things.

Pattern 3

Default, then check

Mutate harmless defaults first, then validate the final result. Fewer people are blocked and the rules still hold.

Pattern 4

Exceptions with expiry

Every exception carries a reason, an owner and an end date, so the rulebook never silently weakens.

Pattern 5

Layered ownership

Global safety rules belong to the platform team, local conventions belong to application teams.

Pattern 6

Policy library with tests

A shared, versioned set of policies with test cases acts like a product that teams can trust.

Patterns that hurt

ANTI-PATTERN-04 Avoid
Problem

Enforcing a large batch of new deny rules all at once, without any audit period.

Why It’s Harmful

Teams are blocked without warning, deployments fail, and the policy program loses credibility on day one.

Correct Approach

Introduce rules one family at a time through audit, warn and deny stages, with announcements before each step.

ANTI-PATTERN-05 Avoid
Problem

Policies that match every resource kind in every namespace, including system namespaces.

Why It’s Harmful

Evaluation work multiplies, latency rises, and a single mistake can block the cluster’s own repair tools.

Correct Approach

Match only the kinds and operations you need, and exclude system areas by default.

ANTI-PATTERN-06 Avoid
Problem

Editing policies directly in the live cluster with no review and no history.

Why It’s Harmful

Nobody knows who changed what, rollbacks are guesswork, and the cluster drifts away from what the team believes it has.

Correct Approach

Keep policies in version control, review changes, and let an automated pipeline apply them.

24Best Practices and Common Mistakes

A short checklist of habits that separate calm policy programs from stressful ones.

Best Practices

  • Start from the public policy library and the Pod Security Standards instead of inventing basics
  • Write clear, helpful messages that explain the fix
  • Run several admission controller replicas spread across zones
  • Test every policy with passing and failing examples
  • Keep everything in Git and deploy through a pipeline
  • Watch metrics and reports, and alert on engine health

Common Mistakes

  • Turning on deny rules without an audit period
  • Forgetting to exclude system namespaces and Kyverno’s own namespace
  • Letting developers create exceptions freely
  • Slow external lookups on every request
  • Running a single replica in production
  • Ignoring deprecation notices until the last minute
i
Start Small

A good first week is three audit-mode policies: require ownership labels, require resource limits, and block privileged containers. Read the reports, talk to the owners of what fails, and grow from there.

!
Policy Is Not a Substitute for Everything

Admission policies are one layer of defense. You still need access controls, network isolation, runtime monitoring, patching and a secure build pipeline. Kyverno strengthens these layers but does not replace them.

Three questions before adding any rule

1

What risk does it reduce?

If you cannot name the risk in one sentence, the rule may not be worth the friction.

2

Who will it affect?

Read the audit report and talk to those teams before enforcement begins.

3

How will we know it is working?

Pick a metric or report view that shows whether violations are going down.

25Real-World and Industry Examples

Different industries use the same tool for different worries. Here is how the ideas look in practice.

Financial services: proving control to auditors

Banks and payment companies must show regulators that sensitive workloads follow strict rules. Policy reports give them a living record: which resources comply, which do not, and how that changed over time. Image verification ensures only approved, signed software runs in payment systems.

Telecommunications: many clusters, one rulebook

Telecom operators run large numbers of clusters across many locations. A single set of policies, stored in Git and applied everywhere, gives consistent security without hand-tuning each site. Generation policies prepare each new site with the same defaults.

Software companies: the paved road for hundreds of engineers

Product companies with large engineering teams use Kyverno to give developers safe defaults. Mutation adds the standard labels and security settings. Validation catches mistakes during the pull request stage through command-line checks, and again at the cluster door.

Education and research: short-lived environments

Universities and training platforms create hundreds of temporary environments for classes and experiments. Time-to-live cleanup removes them automatically after the course, keeping costs predictable.

Healthcare technology: protecting sensitive data

Health platforms must keep patient data strictly separated. Generation policies create isolation rules for each tenant, and validation prevents workloads from mounting host paths or running with elevated rights.

“The best policy program is the one developers barely notice, because the safe path is already the easy path.”

26Inside a Request: The Full Data Flow

Let us follow one single pod creation from the developer’s keyboard all the way to a stored object, noticing every moment Kyverno gets involved.

Understanding the exact sequence of events removes most of the mystery from Kyverno. When something surprising happens, you can ask yourself at which step it happened. The journey has more steps than most people expect, and each one has a different owner and a different failure mode.

sequenceDiagram
  participant Dev as Developer
  participant API as API Server
  participant KY as Kyverno Admission
  participant ET as etcd Store
  participant RP as Reports Controller
  Dev->>API: Create pod request
  API->>API: Authenticate and authorize
  API->>KY: Mutating webhook call
  KY-->>API: Changes to apply
  API->>API: Check object shape
  API->>KY: Validating webhook call
  KY-->>API: Allow or deny with message
  API->>ET: Save object if allowed
  KY->>RP: Send result for reporting
  API-->>Dev: Success or error message
        
FIG 7 — One pod creation, step by step, with Kyverno’s two visits
1

The request is received

The API server confirms who is calling and whether they are allowed to create pods in that namespace. Kyverno has not been involved yet, and a request rejected here never reaches it.

2

The API server checks its webhook list

Kyverno registers webhook configurations that describe which kinds and operations it wants to see. The API server compares the request with that list and only calls Kyverno when there is a match. This is why narrow matching saves real effort.

3

The mutating visit

Kyverno looks at every mutating policy that matches, builds the list of changes, and sends back instructions describing them. The API server applies the changes to the object in memory.

4

The shape check

Kubernetes itself confirms that the final, changed object is still valid. If a mutation produced something malformed, the request fails here with a clear complaint about the object, not about policy.

5

The validating visit

Kyverno evaluates every matching validation and image verification policy against the final object. It answers allow, or deny with a message, and warnings can travel back with an allow.

6

Storage and reporting

If every checkpoint agrees, the object is saved. In parallel, results are passed to the reporting machinery so that audit outcomes can appear in policy reports.

Simple Analogy

Imagine mailing a package through a very careful postal service. First the clerk checks your ID. Then a packing specialist adds any missing padding and labels. Then an inspector examines the final parcel and either stamps it or sends it back with a note. Finally, the parcel is stored and a record is added to the logbook. Kyverno is both the packing specialist and the inspector, and it visits at two different moments.

Why this order has consequences

Because mutation comes before validation, validation rules always see the finished object. This means you can rely on a mutation policy to add a label and then write a validation policy that requires the label, and the two will agree. It also means that when you test a validation policy using a raw manifest, you may get a different result from the live cluster, because the live cluster applied changes first. Good test suites account for this by testing the mutated form as well.

!
Common Surprise

Many other mutating webhooks may also be running in the cluster, such as service mesh helpers. The order between different tools is controlled by Kubernetes, and Kyverno may be asked to run again if another tool changes the object afterwards. Reinvocation behavior is one reason that mutation policies should be written to give the same answer when applied twice.

27Policy Evaluation Internals

Behind each allow or deny is a small pipeline of matching, preparing data, running expressions and building an answer.

When the admission controller receives a call, it does not read policies fresh from the cluster each time. That would be far too slow. Instead, it keeps a cache of policies that it updates as policies change. Policy resources are watched, and when one is created, edited or removed, the cache updates within moments. The expressions inside CEL-based policies are compiled ahead of time into an efficient form, so that at request time the engine only needs to run them against the incoming data.

The evaluation pipeline

flowchart LR
  A["Incoming request"] --> B["Find matching policies from cache"]
  B --> C["Apply exclusions and exceptions"]
  C --> D["Load context and variables"]
  D --> E["Run compiled expressions"]
  E --> F["Combine results"]
  F --> G["Build response and report entry"]
        
FIG 8 — The evaluation pipeline inside the admission controller
Stage 1

Match

Policies whose kind, operation, namespace and label selectors fit the request are selected from the in-memory cache.

Stage 2

Filter

Exclusions, resource filters and any matching policy exceptions remove the resource from consideration for specific rules.

Stage 3

Prepare

Variables are computed and any needed context, such as config map contents, is loaded and cached.

Stage 4

Evaluate

Compiled expressions run. Each one returns true or false, and false triggers the chosen action with its message.

Simple Analogy

A teacher grading a pile of homework does not rewrite the answer key for each paper. The key is prepared once, kept at hand, and each paper is quickly compared against it. Policy caching and pre-compiled expressions are the prepared answer key.

Pod controllers and automatic rule extension

People rarely create bare pods. They create deployments, stateful sets, daemon sets and jobs, which then create pods. If a policy about pods only matched pods, it would catch a bad deployment late, when the deployment’s controller tries to create the pods and fails, leaving the developer with a confusing situation where the deployment exists but no pods appear. Kyverno’s legacy engine had an automatic feature that extended pod rules to the controllers that make pods. The newer policy types handle this through their own matching options and the way policies are written, so check the current documentation for how your chosen policy type treats pod-creating resources. The goal is always the same: tell the developer about the problem at the earliest, most visible moment.

i
Fail Early

A rejected deployment gives an instant, clear message at apply time. A rejected pod inside a running controller produces a slow, hidden failure that people find only by digging through events. Aim for early feedback.

Idempotence: running twice must equal running once

A well-behaved mutation policy gives the same final object whether it runs once or several times. If each run added another copy of the same item, repeated runs would pile up duplicates. Writing policies that check the current state before changing it, and that describe the desired end state, avoids this trap.

ANTI-PATTERN-07 Avoid
Problem

A mutation that appends an item every time it runs, without checking whether the item is already present.

Why It’s Harmful

When the request is reprocessed after another tool changes the object, the item is added again. Objects grow strange duplicates that confuse applications and operators.

Correct Approach

Describe the end state, check before adding, and test the policy by running it twice on the same object.

28The Policy Lifecycle: From Idea to Retirement

Policies are living things. They are proposed, tested, enforced, tuned and eventually retired, and each stage needs an owner.

Many organizations treat policies as a one-time installation. Over the years, the rule list grows and nobody remembers why half of them exist. Some rules block harmless work, some duplicate each other, and some protect against problems that were fixed long ago. A healthy program manages the whole lifetime of every rule with the same discipline used for software products.

1

Propose

Someone writes down the risk, the affected workloads and the proposed rule. A short written proposal prevents rules that exist only because of someone’s hunch.

2

Build and test

The rule is written, given test cases, reviewed by a second person and checked with the command-line tools.

3

Observe

The rule runs in audit mode. The reports are shared with the teams affected, and fixes are tracked.

4

Enforce

When the violation count is acceptable, the rule moves to warn and then deny, with an announcement at each step.

5

Tune

Exceptions, false positives and feedback are reviewed regularly. The rule is sharpened or relaxed based on facts.

6

Retire

When the risk disappears, for example because a platform feature now covers it, the rule is removed and the removal is recorded.

Simple Analogy

Think of a garden. You plant carefully, water, watch what grows, trim what is too wild, and eventually remove what has died. A garden that is only planted and never tended turns into a jungle. A rulebook behaves the same way.

Ownership and metadata

Every policy should name an owner, a reason, a severity and a link to its proposal. Kyverno policies can carry annotations and labels for this purpose, and the public policy library uses annotations to describe each rule’s title, category and purpose. Adopting a consistent set of annotations makes it easy to build a catalog that anyone can search. A question like “which policies protect payment workloads, and who owns them?” should have a one-minute answer.

Versioning and communication

Treat changes to policies like changes to a public interface. Small fixes can flow quickly. Changes that make a rule stricter should be announced in advance with a date. A short, regular newsletter or channel post listing upcoming policy changes does more for trust than any technical feature.

Example: The quarterly policy review

Every three months, the platform and security teams review the list of policies, the number of violations over time, the exceptions granted and the support questions raised. They retire policies nobody needs, merge duplicates and decide which audit rules are ready to be enforced.

i
Measure Friction

Track how many deployments were rejected, how many support requests mention policy, and how long it takes teams to fix a violation. A policy program that produces constant support requests is telling you its messages or rollout plan need work.

29Compliance and Audit Evidence

For many companies, the main reason to adopt policy-as-code is to answer auditors quickly and honestly.

Industry standards and regulations ask for controls such as least privilege, separation of tenants, approved software only, encryption in transit and logging. Auditors do not simply accept “we have a rule”. They ask for proof that the rule applies everywhere and that exceptions are controlled. Doing this by hand with spreadsheets and screenshots is slow and easily becomes out of date. With Kyverno, the policy is the written rule, the admission result is the enforcement, and the policy report is the evidence.

Evidence 1

The rule itself

Policies stored in Git show exactly what is required, who approved it and when it changed.

Evidence 2

Enforcement history

Git history, review records and rollout announcements show the rule was introduced deliberately.

Evidence 3

Current compliance

Policy reports show which live resources pass or fail right now, including long-existing ones.

Evidence 4

Exception register

Exception resources, with owners and end dates, show exactly where and why a rule was bent.

Simple Analogy

A restaurant inspector wants to see the written food-safety rules, the temperature logs and the list of any special approvals. A kitchen that keeps these neatly in one binder passes quickly. Policies, reports and exceptions are the binder for your cluster.

Mapping policies to controls

A practical approach is to build a simple mapping table. Each row names a control from the standard you follow, the Kyverno policy that supports it, the mode it runs in, and where the evidence can be found. This table becomes the first thing you hand to an auditor, and it shows you gaps, which are controls that no policy supports yet.

Control ThemeKyverno SupportEvidence
No privileged workloadsValidation policy based on Pod Security StandardsPolicy report with zero failures
Approved software onlyImage verification policyAdmission denials and signature records
Tenant separationGeneration policy for network rules and quotasGenerated resources present in every tenant namespace
Change controlPolicies stored in Git with reviewsPull request history
Controlled deviationsPolicy exceptions with expiryException register
!
Policy Is Not a Certificate

Having policies does not by itself make an organization compliant. Standards also cover people, processes and many systems outside Kubernetes. Kyverno gives strong technical evidence for the controls it touches, and the rest must be covered elsewhere.

i
Keep Reports Over Time

Reports show the current state. If auditors ask about the past, you need a place that stores snapshots or metrics history. Export report data to your monitoring or data platform on a regular schedule.

30Troubleshooting Kyverno Like a Detective

When something goes wrong, a calm, ordered investigation beats guesswork every time.

Almost every Kyverno problem falls into one of a few families: a request was denied and the developer does not understand why, a policy seems to be ignored, a generated resource did not appear, or the cluster has become slow. For each family there is a short list of checks, and following the list in order finds the cause quickly.

Family 1: “Why was my request denied?”

1

Read the message carefully

The rejection names the policy and the rule that blocked the request. Start there, and do not skim.

2

Look at the policy’s intent

Read the policy’s description and annotations to learn why the rule exists and who owns it.

3

Test the same manifest locally

Run the command-line tool on the manifest against the policy and confirm it fails the same way, remembering to consider mutations that the live cluster adds first.

4

Fix the manifest or request an exception

Most of the time the correct answer is to fix the manifest. If there is a real need, follow the exception process.

Family 2: “My policy is being ignored”

Check 1

Is it ready?

Inspect the policy status. A policy that failed to compile or load will not be applied, and the status says why.

Check 2

Does it match?

Compare the policy’s kind, operation, namespace and label selectors with the real request. A single missing operation is a common cause.

Check 3

Is it filtered or excepted?

Resource filters, namespace exclusions and policy exceptions may be excusing the resource.

Check 4

Is it only auditing?

A policy in audit mode lets the request through and records a report entry. Check the action setting before assuming a bug.

Family 3: “My generated resource never appeared”

First confirm that the background controller is running and healthy. Then check its permissions, because it can only create what its service account allows. Next confirm the trigger really matches, and read the controller’s logs for errors about the target resource. Finally look at whether the policy’s synchronization and update settings are what you expect.

Family 4: “Everything feels slow”

Look at admission latency metrics and find out whether the slowness began after a particular policy change. Inspect policies that make external calls or load large amounts of context. Check whether the admission controller pods are short of memory or processing power, or whether requests are queuing. Narrowing policy matching often gives the biggest improvement.

Simple Analogy

A doctor does not start with surgery. The doctor asks questions, checks simple vital signs, and only then orders bigger tests. Troubleshooting follows the same ladder: cheap, simple checks first, expensive investigations last.

i
Write a Runbook

Turn these four families into a one-page runbook for your support channel. When developers can self-diagnose the common cases, the platform team gets its time back.

31Beyond the Admission Webhook

Kyverno began as a Kubernetes admission tool, but the same policy idea can guard many other doorways.

The most visible place for Kyverno is the Kubernetes admission path, but the ideas apply anywhere data needs to be checked against rules. Over time, the project has grown tools that work before and beyond admission. Public CNCF material about the graduation also states that upcoming releases aim to extend policy enforcement to additional control points across the cloud native stack, including gateways for artificial intelligence and Model Context Protocol traffic. Because plans can change, treat this as a direction rather than a promise, and check the roadmap when you plan.

Doorway 1

Developer laptops and pipelines

The command-line tool checks manifests in pull requests and build pipelines, long before they reach a cluster.

Doorway 2

Existing cluster contents

Background scans and reports look at what is already running, which admission control alone cannot see.

Doorway 3

Other JSON data

The project has explored applying policies to any structured data, such as cloud configuration files, not only Kubernetes resources.

Doorway 4

Emerging gateways

Gateways that sit in front of new kinds of services are a stated area of future interest for the project.

Simple Analogy

A security guard at the front door is useful, but a well-run building also checks packages at the loading dock, badges at the elevator and cameras in the car park. The same careful thinking, applied at several doors, creates real safety. Kyverno’s long-term idea is one rulebook reaching many doors.

Shift left: catch problems sooner

The phrase shift left means moving checks earlier in the journey, toward the developer. A rule violation found on a laptop costs a few seconds to fix. The same violation found in production costs a deployment failure, a message to the platform team and a lost afternoon. Running the same policies in pipelines and again at admission gives two chances to catch an issue, and the developer usually meets it at the cheapest moment.

Advantages

  • One rulebook used in pipelines and in clusters
  • Cheaper and faster feedback for developers
  • Cluster doors act as a safety net for anything that slips through
  • Same language and tooling for security and platform teams

Disadvantages / Trade-offs

  • Pipeline results can differ from live results if mutation and context are not simulated
  • Extra places to keep policy versions in sync
  • Teams must learn to read the same messages in more than one setting
!
Keep Policy Versions Aligned

If the pipeline uses last month’s policies and the cluster uses this month’s, developers will pass the pipeline and fail at the cluster. Publish policies from one source of truth and pin the same version in both places.

32Day-Two Operations: Upgrades, Backup and Capacity

Installing Kyverno is day one. Keeping it healthy for years is day two, and it deserves the same planning.

A policy engine on the critical path of every deployment is a piece of platform infrastructure, so it needs regular care. The tasks are not exciting, but skipping them is how teams end up with a surprise outage or a security gap.

Upgrades

Kyverno releases frequently, and the project supports the current release and the one before it for patches. Falling several releases behind removes you from that safety net. A reliable routine looks like this: read the release notes and upgrade guide, note any removed or changed features, upgrade a test cluster first, run your policy tests and watch reports and metrics, and only then upgrade production, one cluster at a time. Because the project is in the middle of retiring its legacy policy types, upgrade notes deserve extra attention in the coming releases.

1

Read the notes

Find deprecations, removals and new defaults that may change behavior.

2

Rehearse in a test cluster

Apply the upgrade and run your full policy test suite and sample workloads.

3

Roll out gradually

Upgrade lower-risk clusters first and watch latency, errors and reports before moving on.

4

Keep a way back

Know how you would return to the previous version if something goes wrong.

Backup and disaster recovery

If policies live in Git and are applied by an automated pipeline, rebuilding a lost cluster is mostly a matter of reinstalling Kyverno and letting the pipeline apply the policies again. That is a strong reason to keep Git as the source of truth. Also keep the installation settings, such as replica counts and webhook behavior, in version control. Remember that reports are generated data and can be rebuilt by background scans, although historical report data lives only in whatever monitoring system you exported it to.

Simple Analogy

If every recipe in a restaurant is written in a shared cookbook, a fire in one kitchen does not destroy the menu. The cook simply opens the cookbook in a new kitchen. Git is the cookbook, and the cluster is just one kitchen.

Capacity planning

Traffic
Request rate on matching kinds drives admission load
Policies
More policies and heavier context mean more work per request
Size
Large clusters mean larger caches and longer background scans

Start with the recommended replica counts from the documentation, then adjust based on measured latency and memory use. Watch trends rather than single numbers: a slow, steady growth in memory or latency is an early warning that you will soon need more capacity or fewer, better-targeted policies. Load test in a staging cluster by creating many resources quickly, so you learn the limits before production does.

i
Practice the Bad Day

Once a quarter, rehearse a failure: stop the admission controller in a test cluster and observe what happens, or deploy a deliberately broken policy and practice the rollback. Teams that practice recover in minutes. Teams that do not recover in hours.

33Frequently Asked Questions

Short, direct answers to the questions people ask most often when they start working with Kyverno.

Q1Does Kyverno replace Kubernetes role-based access control?

No. Access control decides who is allowed to perform an action. Kyverno decides whether the content of the request is acceptable. The two work together, and neither replaces the other.

Q2Do I need to learn a new programming language?

Policies are Kubernetes resources, so the surrounding structure is familiar. The newer policy types use CEL for their conditions, which is a small expression language that is much simpler than a general programming language and is shared with Kubernetes’ own native policies.

Q3What happens to resources that already exist when I add a policy?

Existing resources are not blocked or deleted by a validation policy. The background scan checks them and records the results in reports, so you can see what would fail. Mutation and generation of existing resources are separate, deliberate features.

Q4Can Kyverno slow down my cluster?

It adds a small amount of time to matching requests, because the API server waits for its answer. Narrow matching, enough replicas, cached lookups and avoiding slow external calls keep that cost low.

Q5What if Kyverno goes down?

It depends on the webhook failure setting. Fail closed rejects covered requests while Kyverno is unavailable. Fail open lets them through unprotected. Running multiple replicas and monitoring health greatly reduces the chance of either situation.

Q6Should I use Audit or Enforce?

Start with audit so you can see the impact, add warnings to educate people, and move to enforcement when the rule is understood and teams are ready. Critical safety rules usually end up enforced.

Q7Can I give teams their own policies?

Yes. Namespaced policy types let teams manage rules inside their own namespaces, while cluster-wide rules stay under platform and security control.

Q8Is it safe to keep using ClusterPolicy?

It still works today but is deprecated, with removal planned for a later release. Plan the migration now and check the official release notes for the exact schedule.

Q9Where do I find ready-made policies?

The Kyverno project maintains a public policy library covering Pod Security Standards, best practices and many compliance needs. It is a good starting point and a great way to learn how experienced authors structure rules.

Q10Can Kyverno check resources before they reach the cluster?

Yes. The command-line tool can apply policies to manifest files in a developer’s pipeline, so violations are found during code review instead of at deployment time.

Q11Does Kyverno work with GitOps tools?

Yes. Policies are ordinary resources, so GitOps tools can apply and manage them like anything else. This is the recommended way to handle policies at scale.

Q12Can one policy do several jobs at once?

It is better not to. With the newer policy types, each job has its own dedicated type, and small single-purpose policies are easier to test, own and retire.

34Summary and Key Takeaways

Kyverno turns the rules your organization cares about into living, testable, versioned resources that the cluster itself enforces. It sits at the admission stage of the Kubernetes request path, where it can check, change and create resources, verify the software supply chain, clean up clutter and report on everything it sees. Its recent move to CEL-based policy types brings it in line with Kubernetes’ own direction, and its graduation within the CNCF signals maturity and long-term stability. The technology is only half of the story. Success also depends on careful rollouts, clear messages, narrow matching, healthy replicas, honest exceptions and steady communication with the teams you are trying to help.

Key Takeaways

  • Kyverno guards the admission doorway — it joins the API server’s request path through webhooks to validate, mutate, generate and verify resources before they are stored.
  • Specialized controllers do specialized work — the admission, background, reports and cleanup controllers scale and fail independently and hold separate permissions.
  • CEL-based policy types are the future — ValidatingPolicy, MutatingPolicy, GeneratingPolicy, ImageValidatingPolicy and related types replace the deprecated legacy policies, so plan your migration early.
  • Roll out in stages — move every rule through audit, warn and deny, using reports as your guide, and keep all policies in Git.
  • Reliability is part of security — run multiple replicas, choose the failure behavior deliberately, narrow your matching, and keep a recovery plan.
  • Exceptions need owners and end dates — controlled, documented departures keep strong rules alive instead of letting them be deleted.
  • Make the safe path the easy path — mutation and generation provide safe defaults so teams move quickly without needing to remember every rule.