Helm can't iterate over range from set-file
--set-file
sets the contents of the variable to the text contents of the file; it doesn’t try to interpret it at all. (Somewhat described in this section of the Helm docs; note the example there is a JavaScript script being embedded in a ConfigMap.) That means you need to tell Helm to parse the file. Helm includes a minimally-documented fromYaml
function that can do this.
When you iterate through the contents of the value, try explicitly parsing it first:
{{- range $key, $val := fromYaml .Values.secretmap }}
...
{{ end }}