Values and defaults
On this page
Beyond where a value is used, helm-schema reads how the chart sets its defaults: in the composed
values.yaml and in default calls in the templates.
The composed values#
Before analysis, helm-schema builds one values document, as Helm does, from:
- the chart’s own
values.yaml; - each subchart’s defaults, under its dependency key;
- each subchart’s
globalvalues, merged into the top-levelglobal.
It shapes the schema and gives each path its default. --no-subchart-values leaves out the defaults
of the subcharts under charts/; see Subcharts.
Values files passed with -f or --values only add documentation: their comments can become
descriptions, but they never add a type or a key.
Types from default literals#
A common Helm pattern ships null in values.yaml and falls back to a literal in the template:
replicaCount: null
nameOverride: nullapiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.nameOverride | default "defaults" }}
spec:
replicas: {{ .Values.replicaCount | default 1 }}In default <literal> .Values.X, or .Values.X | default <literal>, the literal gives X its
type: a string, an integer, a number or a boolean. With the null default, the schema is a union:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"global": {},
"nameOverride": {
"anyOf": [
{
"not": {
"anyOf": [
{
"const": true
},
{
"not": {
"const": 0
},
"type": "number"
},
{
"minLength": 1,
"type": "string"
},
{
"minItems": 1,
"type": "array"
},
{
"minProperties": 1,
"type": "object"
}
]
}
},
{
"type": "null"
},
{
"type": "string"
}
]
},
"replicaCount": {
"anyOf": [
{
"not": {
"anyOf": [
{
"const": true
},
{
"not": {
"const": 0
},
"type": "number"
},
{
"minLength": 1,
"type": "string"
},
{
"minItems": 1,
"type": "array"
},
{
"minProperties": 1,
"type": "object"
}
]
}
},
{
"type": "integer"
},
{
"type": "null"
}
]
}
},
"type": "object",
"x-helm-schema-generated": true,
"x-helm-schema-policy": {
"annotation-format-version": 1,
"authoring": {
"declared-types": "assert",
"root": "closed"
},
"modifiers": {
"overrides": {
"count": 0,
"digest": "4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945"
},
"reference-mode": "fully-inlined"
},
"narrowing": [],
"policy-fingerprint": "8a5e8a392fff0994ab4c850bc117a320c0dfe56736e845b27be81a7404a4384f",
"policy-vocabulary-version": 2,
"requested-profile": "full",
"resolved": {
"kind-partitions": true,
"local-conditionals": true,
"root-anchored-conditionals": true,
"terminal-clauses": true
}
}
}replicaCount and nameOverride each accept:
- a value Helm treats as empty:
null,"",0,falseor an empty list or map, which thedefaultreplaces. This is the first member,notof the non-empty forms. null, the shipped placeholder.- the literal’s type: an integer for
replicaCount, a string fornameOverride.
A fallback that is not a literal, such as default .Chart.Name .Values.X or
default (printf "%s" .Y) .Values.X, gives no type, since its type is only known when Helm runs.
It still counts as a fallback for required fields.
Declared defaults and the closed root#
Two checks in the default schema come from how the chart is written rather than from what Helm needs (How it works explains the difference). Each has a flag that turns it off without changing any other constraint:
--open-root: leaves outadditionalProperties: falseat the values root, so a top-level key that no template reads passes, misspelled or not. Nested objects, Kubernetes types and requirements stay as they are, and a dependency’s values stay open either way.--declared-types annotate: keeps each default invalues.yamlas documentation, with its name and description, but no longer asserts its type. With the default,assert, a chart that shipsreplicas: 1rejectsreplicas: "3"where nothing else types the value.
The schema records both settings in its x-helm-schema-policy annotation, under authoring.
Helm’s global is always allowed at the values root and at every dependency’s root, in any shape.
Where templates read members of it, those members are checked, and the rest stays open to the values
other charts share.
Required fields#
The schema requires a value that the templates always render, where a missing value would fail the
render or give an invalid resource. Helm checks the values merged with the chart’s defaults, so a
key the chart’s values.yaml sets is only missing when a user sets it to null.
--infer-required also requires the values a template tests unconditionally, at its top and inside
no other condition:
{{- if .Values.provider }}
...
{{- end }}helm-schema ./mychart --infer-requiredA value with any default fallback is never required this way, since the chart handles it being
unset:
{{ default "myapp" .Values.nameOverride }}--infer-required goes beyond what Helm needs, so it is off by default and only the command line
turns it on; helm-schema.yaml cannot.
Note
Requiredness comes from unconditional tests, not from a missing default. A value without a default that is only used inside another condition is not required, since the template does not need it in every render.