I have a helm chart as follows
dns_entries:
cluster1: xx.xx.xx.xx
cluster2: xx.xx.xx.xx
The cluster value is also set dynamically while installing the helm chart. In the templates, I need to choose this dynamically from the map above
{{- if hasKey .Values.dns_entries .Values.clusterId }}
clusterIP: {{ .Values.dns_entries.{{ .Values.clusterId }} }}
{{- end }}
How can I implement the above correctly ?
Thanks!
I figured out that I needed to iterate over the map with built-in functions.
{{- if hasKey .Values.dns_entries .Values.clusterId }}
{{- range $key, $value := .Values.dns_entries }}
{{- if eq $key .Values.clusterId }}
clusterIP: $value
{{- end }}
{{- end }}
{{- end }}