OpsCanary
kubernetessecurityPractitioner

Making Kyverno Think It's in Production: A Practical Guide

5 min read CNCF BlogJul 22, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

In the world of Kubernetes, ensuring your policies are robust before they go live is crucial. Kyverno, a Kubernetes-native policy engine, allows you to validate, mutate, and generate resources while enforcing security and compliance rules as code. However, testing these policies in a production-like environment can be challenging. That's where the CLI's ability to simulate production conditions comes into play, allowing you to catch issues early and avoid costly mistakes.

The CLI utilizes resolveResourcesMockData, a translation layer that decodes each manifest into an unstructured map. This process wraps the result into an []interface{} slice, enabling the policy engine to evaluate the policy as it would in a live environment. This means you can trust the results you get from your tests. For example, you can enable offline testing of HTTP and Envoy authorization policies, although the specifics for these configurations are not detailed. The key here is that you can run your policies against realistic data, ensuring they behave as expected before deployment.

In production, you need to be aware of the version you're using—Kyverno v1.17 and v1.18 are the relevant versions. While the CLI provides a powerful mechanism for testing, be cautious of the potential for coding errors, such as the one indicated by the panic message: "you must register resource to list kind." This highlights the importance of ensuring all resources are properly registered before running your tests. Overall, using Kyverno's CLI effectively can save you from headaches down the line, but it requires diligence and attention to detail.

Key takeaways

  • Use resolveResourcesMockData to simulate production conditions for policy evaluation.
  • Test policies offline to catch issues before they reach your cluster.
  • Ensure all resources are registered to avoid coding errors during testing.
  • Leverage Kyverno v1.17 and v1.18 for the latest features and fixes.

Why it matters

Testing policies in a production-like environment helps prevent security and compliance issues from reaching your live cluster, ultimately safeguarding your applications and data.

Code examples

YAML
kyverno-test.yaml
Go
panic: coding error: you must register resource to list kind

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
Better StackSponsor

Unified observability — logs, uptime monitoring, and on-call in one place. Used by 50,000+ engineering teams to ship faster and sleep better.

Try Better Stack free →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.