Helm template control structures
The way in which templates are generated can be managed by chart developers thanks to the functionality provided by control structures. Included in the actions
component of the Go
templates, control structures enable fine-grained flow control for determining the types of resources that should be generated and how they are rendered.
The following control-structure keywords are available:
if
/else
—Creating conditional blocks for resource generationwith
—Modifying the scope of resources being generatedrange
—Looping over a set of resources
There are occasions where portions of a template would need to be included or excluded based on some sort of condition. In this situation, an if
/else
action can be used. Here is a basic example for conditionally determining whether to include a readiness probe as part of a deployment resource:
{{- if .Values.readinessProbe.enabled }} readinessProbe: httpGet...