Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm: Get value from a Map where the key is variable

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!

like image 862
Taseer Ahmed Avatar asked Jun 06 '26 01:06

Taseer Ahmed


1 Answers

https://helm.sh/docs/chart_template_guide/function_list/

get

Given a map and a key, get the value from the map.

get $myDict "key1"

get .Values.dns_entries .Values.clusterId
like image 91
jamylak Avatar answered Jun 10 '26 17:06

jamylak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!