Helm Schema Validation
What you'll learn: How to define JSON schemas that validate values.yaml files and catch configuration errors before they reach your cluster.
Why Validate Values?
When you customize Helm charts with values.yaml, typos or incorrect data types can cause deployment failures—or worse, silent misconfigurations. A missing quote, a boolean where a string belongs, or a port number out of range can break your application. Helm schema validation acts like a safety net at the border: it checks your values before any templates are rendered or Kubernetes resources are created.
How It Works
You create a values.schema.json file in your chart's root directory using JSON Schema format (draft 7 or later). This schema defines:
- Required fields (must be present)
- Data types (string, number, boolean, array, object)
- Constraints (min/max values, string patterns, enum options)
- Nested structure (for complex value hierarchies)
When someone runs helm install or helm upgrade, Helm automatically validates the provided values against this schema. If validation fails, Helm rejects the operation with a clear error message—no broken deployments.
Example Schema Snippet
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"replicaCount": {
"type": "integer",
"minimum": 1
},
"service": {
"type": "object",
"properties": {
"port": {"type": "integer", "minimum": 1, "maximum": 65535}
},
"required": ["port"]
}
},
"required": ["replicaCount"]
}
This ensures replicaCount is a positive integer and service.port exists within valid port ranges.
Key Takeaway: Helm schema validation uses JSON Schema to enforce correctness rules on values.yaml, catching configuration mistakes early and preventing broken deployments—think of it as compile-time checks for your deployment configuration.