Reputation: 34099
I have the following define
definition in helm:
{{- define "svc.envVars" -}}
{{- range .Values.envVars.withSecret }}
- name: {{ .key }}
valueFrom:
secretKeyRef:
name: {{ .secretName }}
key: {{ .secretKey | quote }}
{{- end }}
{{- range .Values.envVars.withoutSecret }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
{{- end }}
and I am going to use it in deployment.yaml
containers:
- name: {{ .Release.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.envVars.enabled }}
env:
{{- include "svc.envVars" . | indent 10 }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
in values.yaml
it is defined as follows:
envVars:
enabled: false
withSecret: []
withoutSecret: []
then I tried to render:
helm template --debug user-svc \
--set image.tag=0.1.0 \
--set image.repository=user-svc \
--set envVars.enabled=true \
--set envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw \
--set envVars.withSecret[1].key=MYSQL_URL,envVars.withSecret[1].secretName=mysql_name,envVars.withSecret[1].secretKey=mysql_pw \
./svc
it shows me:
zsh: no matches found: envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw
When I set the variables manually in values.yaml
:
envVars:
enabled: false
withSecret:
- key: POSTGRES_URL
secretName: postgres_name
secretKey: postgres_pw
- key: MYSQL_URL
secretName: mysql_name
secretKey: mysql_pw
withoutSecret:
- name: NOT_SECRET
value: "Value of not serect"
then render it with:
helm template --debug user-svc \
--set image.tag=0.1.0 \
--set image.repository=user-svc \
--set envVars.enabled=true \
./svc
then it works as expected.
What am I doing wrong?
Upvotes: 7
Views: 2170
Reputation: 952
I had the same issue. Due to the fact, that ´[´ and ´]´ are interpreted by zsh.
You can use noglob
to disable the globals. So, ´[´ and ´]´ are not interpreted.
noglob helm template --set lorem[0].ipsum=1337
In your example:
noglob helm template --debug user-svc \
--set image.tag=0.1.0 \
--set image.repository=user-svc \
--set envVars.enabled=true \
--set envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw \
--set envVars.withSecret[1].key=MYSQL_URL,envVars.withSecret[1].secretName=mysql_name,envVars.withSecret[1].secretKey=mysql_pw \
./svc
Sources:
Upvotes: 16