Kubernetes 1.30: Validating Ad... Note

Kubernetes 1.30: Validating Admission Policy Is Generally Available

Kubernetes 1.30 introduces ValidatingAdmissionPolicy, a declarative alternative to validating admission webhooks. It provides a more concise and straightforward way to define admission control policies. To migrate from webhooks, simply recreate the policy validations as expressions using CEL, a declarative language for expressing conditions.Kubernetes 1.28 introduced Variable Composition, allowing for the reuse of sub-expressions, and support for the optional CEL library, which simplifies working with optional fields.To create a policy, define the matchConstraints to specify when the policy should be applied, and the validations to define the conditions that must be met. The failurePolicy determines the action to take if a validation fails (Fail or Warn).Bind the policy to a namespace using a ValidatingAdmissionPolicyBinding. By default, actions are set to "Fail," but can be set to "Warn" during development and testing.To monitor the policy, use API server metrics, such as the 95th percentile execution duration and the rate of evaluation, which can be queried using Prometheus Query Language.ValidatingAdmissionPolicies offer several advantages over webhooks, including reduced code complexity, support for policy-first development, and improved performance.As a bonus, you can leverage Variable Composition and CEL to enhance the readability and maintainability of your policies.Remember, the policy evaluation stops after the first failed expression, which differs from warnings-only evaluation.Finally, ensure you have proper monitoring in place to track the performance and effectiveness of your policies.