Inside a
range
loop in Helm template, the context refers to the current item in the loop iteration. This means that when you use.
inside arange
loop, you’re accessing the current item in the loop.
$.
refers to the top-level context that was passed into the template, and you can use it to access properties that are outside of the currentrange
loop.If you want to access the
.Values
variable inside a named template included inside arange
loop, you can pass it as an argument to the template.{{- define “my-template” }}
{{- $myVar := $.Values.myVar }}
{{- printf “myVar: %s” $myVar }}
{{- end }}{{- range .items }}
From ChatGPT and validated/edited by myself
{{- include “my-template” . (dict “Values” $.Values) }}
{{- end }}