How to use variables with .Values in helm template
Asked Answered
S

1

5

I have the following values.yaml:

vrIds:
  - 51
  - 52
51.vip: 169.254.1.1
52.vip: 169.254.1.2

I have the following template:

{{ range $index, $element := .Values.vrIds }}
  vrrp.{{$element}}.vip: <<How do I get the value of $element.vip>>
{{ end }}

How do I get the value of $element.vip for each vrid?

Susann answered 3/10, 2017 at 10:48 Comment(0)
B
12

You need to modify your values.yaml a little:

vrIds:
  51: 169.254.1.1
  52: 169.254.1.2

And use the following construction inside your template files:

{{- range $key, $value := .Values.vrIds }}
  vrrp.{{ $key }}.vip: {{ $value }}
{{- end }}
Bullfight answered 1/11, 2017 at 18:23 Comment(2)
The problem is I have another parameter for each VRID. vrIds: - 51 - 52 51.vip: 169.254.1.1 52.vip: 169.254.1.2 51.master: node-1 52.master: node-2Susann
This answer did the trick for me. I didn't see this listed in the documentation.Lussi

© 2022 - 2024 — McMap. All rights reserved.