OpsCanary
kubernetesupgradesPractitioner

Kubernetes v1.36: Unlocking Declarative Validation for Production

5 min read Kubernetes BlogMay 5, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

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:

Go
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

Go
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 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.