Kyverno 1.19.2 optimizes Kubernetes admission by fixing CEL object conversion overhead
Kyverno eliminates a performance bottleneck where Kubernetes objects were being redundantly parsed for every matched policy, moving complexity from O(policies) to O(1).
Summary
The Kyverno project has released version 1.19.2, which addresses a significant performance inefficiency in its Common Expression Language (CEL) based admission engines. Profiling revealed that the engine was spending approximately 86% of its allocated memory on preparing objects for evaluation rather than executing the actual policy logic.
The issue stemmed from the engine converting raw JSON bytes from the Kubernetes API server into unstructured maps inside the policy evaluation loop. This caused the computational cost to scale linearly with the number of policies applied to a single request. The update moves this conversion process outside the loop, ensuring the object is prepared only once per request.
Technical breakdown of the CEL admission optimization
- Algorithmic Complexity Improvement: The previous implementation resulted in O(policies) complexity for object conversion; the fix reduces this to O(1) per request by reusing a single prepared object across all matched policies.
- Memory Allocation Reduction: In the ValidatingPolicy engine, object conversion previously accounted for 86.8% of total allocations; after the fix, this drops to 2.9%, leaving 'evaluateWithData' as the primary consumer.
- Implementation Strategy: To maintain compatibility, Kyverno converts a copy of the request with the admitted object temporarily blanked out to allow for efficient walking, then splices the object back in to ensure the output matches previous behavior.
- Engine Parity: The optimization was applied to the ValidatingPolicy, MutatingPolicy, and image verification engines to ensure consistent performance gains across different admission types.
Why it matters
This update is critical for Kubernetes administrators running large policy sets, such as Pod Security Standards, as it prevents admission latency from scaling uncontrollably with policy count. It ensures that Kyverno remains a performant alternative to native Kubernetes ValidatingAdmissionPolicy by removing the 'per-policy tax' on serialization.
What to do
- Update to Kyverno 1.19.2 to eliminate the per-policy object conversion overhead in CEL-based admission engines.
- If you run many matched policies (such as the Pod Security Standards), expect significantly lower memory allocations and engine latency after updating.
- Watch for the fix across ValidatingPolicy, MutatingPolicy, and image verification engines, all of which received the same optimization.
Original reference: www.cncf.io →