Reputation: 2781
In a Helm chart, when trying to set the "ingress.hosts[0].host" via the --set command line argument, the "paths" array values specified in the values.yaml file do not get added to the final output.
I want to override the "ingress.hosts[0].host" key for deployment to different DNS zones on the command line. If I add the host to the values.yaml file, it does generate the correct ingress, but this would mean having different values.yaml files instead of re-using the same one, but with a different DNS zone.
ingress.yaml Helm template
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
values.yaml (Notice the single "path" object that should get added to the deployment.yaml file).
ingress:
enabled: true
className: ""
annotations:
kubernetes.io/ingress.class: addon-http-application-routing
hosts:
- host:
paths:
- path: "/"
pathType: Prefix
command line
helm template ./deploy/vehicleregistrationservice --set ingress.hosts[0].host=vehicleregistrationservice.aksapp.io --debug
Invalid deployment file (notice how the "paths" array is empty)
kind: Ingress
metadata:
name: vehicleregistrationservice
labels:
helm.sh/chart: vehicleregistrationservice-0.1.0
app.kubernetes.io/name: vehicleregistrationservice
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "1.16.0"
app.kubernetes.io/managed-by: Helm
annotations:
kubernetes.io/ingress.class: addon-http-application-routing
spec:
rules:
- host: "vehicleregistrationservice.aksapp.io"
http:
paths:
The deployment file is supposed to look like:
kind: Ingress
metadata:
name: vehicleregistrationservice
annotations:
kubernetes.io/ingress.class: addon-http-application-routing
spec:
rules:
- host: vehicleregistrationservice.aksapp.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: vehicleregistrationservice
port:
number: 80
Upvotes: 11
Views: 13403
Reputation: 146
Just had the same problem.
Try something like --set "ingress.hosts[0].host=yourhost.com,ingress.hosts[0].paths[0].path=/"
Upvotes: 13