Kubernetes v1.36: Declarative Validation Graduates to GA
Kubernetes v1.36 introduces Declarative Validation for native types, now generally available. This shifts from handwritten Go code to IDL tags for defining validation rules, enhancing API reliability and predictability. The previous reliance on handwritten code led to technical debt, inconsistencies, and opaque APIs. The solution utilizes validation-gen, a code generator that parses tags to automatically generate Go validation functions. This framework includes various marker tags for presence, constraints, collections, unions, and immutability. A key benefit is "ambient ratcheting", allowing immediate tightening or loosening of validation without breaking existing objects. Declarative validation makes API reviews easier and more consistent with tools like kube-api-linter. The project plans to migrate remaining legacy code and mandate declarative validation for new APIs. This also unlocks future ecosystem benefits, like client-side validation by tools such as kubectl and integration with tools such as Kubebuilder. The migration is ongoing, with opportunities to contribute to the Kubernetes codebase. The document concludes with acknowledgments to contributors, welcoming the declarative future of Kubernetes validation.
validation-gen, a code generator that parses tags to automatically generate Go validation functions. This framework includes various marker tags for presence, constraints, collections, unions, and immutability. A key benefit is "ambient ratcheting", allowing immediate tightening or loosening of validation without breaking existing objects. Declarative validation makes API reviews easier and more consistent with tools likekube-api-linter. The project plans to migrate remaining legacy code and mandate declarative validation for new APIs. This also unlocks future ecosystem benefits, like client-side validation by tools such askubectland integration with tools such as Kubebuilder. The migration is ongoing, with opportunities to contribute to the Kubernetes codebase. The document concludes with acknowledgments to contributors, welcoming the declarative future of Kubernetes validation.