How can I pass an array through a Helm template?

Viewed 3973

I'm using Helm v3.

The issue is that I've a template which gets an input value from a values.yaml file.

I've a parameter that looks as follows:

{{ if .Values.school.students}}
students: {{ .Values.school.students}}
{{ end }}

Now, the actual value of students looks something like this:

students: ["student1", "student2", "student3"]

I need students to be an array but currently it gets passed as a string.

I read a few answers online where it was mentioned that we can use "--set" flag but I'm not clear.

Does anyone know how to fix this?

1 Answers

You can loop through .Values.school.students using range

{{- if .Values.school.students }}
  students: -|
  {{- range .Values.school.students }}
    - {{ . | quote }}
  {{- end }}
{{- end -}}
Related