Kubernetes v1.36: Unlocking Declarative Validation for Production
Declarative Validation is a game changer for Kubernetes users. It addresses the challenge of ensuring that your API objects adhere to specific validation rules without the overhead of manual checks. By allowing developers to embed validation rules directly in their code, it streamlines the process and reduces the risk of errors.
At the core of this feature is the validation-gen code generator. This tool parses the +k8s: tags in your types.go files and automatically generates the corresponding Go validation functions. These functions are then registered with the API scheme, ensuring that your validation logic is tightly integrated with Kubernetes. For example, you can define a ReplicationControllerSpec like this:
type ReplicationControllerSpec struct {
// +k8s:optional
// +k8s:minimum=0
Replicas *int32 `json:"replicas,omitempty"`
}In production, this feature simplifies the validation process significantly. You can leverage Ambient Ratcheting, a safety mechanism that allows you to adjust validation rules without breaking existing objects. This flexibility is crucial when you need to adapt to changing requirements while maintaining backward compatibility. As this feature has reached GA in v1.36, it’s time to adopt it for your Kubernetes applications and enhance your API's reliability.
Key takeaways
- →Use +k8s: tags to define validation rules directly in your types.go files.
- →Leverage the validation-gen code generator to automate Go validation function creation.
- →Utilize Ambient Ratcheting to adjust validation rules without breaking existing objects.
Why it matters
This feature significantly enhances API reliability and reduces manual validation errors, which is critical for maintaining robust Kubernetes applications in production environments.
Code examples
type ReplicationControllerSpec struct {
// +k8s:optional
// +k8s:minimum=0
Replicas *int32 `json:"replicas,omitempty"`
}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 docsUnified 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 →Automate EKS AMI Updates with AI and GitOps
Streamline your Amazon EKS AMI updates using AI-driven risk analysis and GitOps practices. This approach leverages Amazon Bedrock for analysis and ArgoCD for deployment, ensuring zero-downtime updates. Discover how to implement this in your environment effectively.
Preparing for Bitnami Image Removal from ECR Public
Bitnami images will vanish from Amazon ECR Public after June 10th, 2026, leaving many Kubernetes deployments at risk. You need to update your image URIs to avoid service disruptions. This article dives into the steps you must take to ensure a smooth transition.
Kubernetes v1.36: Mixed Version Proxy Moves to Beta
Kubernetes v1.36 brings the Mixed Version Proxy (MVP) to beta, enhancing cluster upgrade safety. This feature ensures requests for resources not recognized by an older API server are properly routed to a newer one, preventing frustrating 404 errors.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.