helm-template get value of the map by key

values.yaml

coins:
  ether:
    host: 10.11.0.50
    port: 123
  btc:
    host: 10.11.0.10
    port: 321
template.yaml
{{- range $key, $val := .Values.coins }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ $key }}
  - env:
    - name: SSH_HOSTNAME
      value: {{ $val.host | quote }}
    - name: SSH_TUNNEL_HOST
      value: {{ $val.port | quote }}
---
{{- end }}

run $ helm template ./helm

---
# Source: test/templates/ether.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: btc
  - env:
    - name: SSH_HOSTNAME
      value: "10.11.0.10"
    - name: SSH_TUNNEL_HOST
      value: "321"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ether
  - env:
    - name: SSH_HOSTNAME
      value: "10.11.0.50"
    - name: SSH_TUNNEL_HOST
      value: "123"
---

label is an array, so the index function will only work with integers, this is a working example:

foolabel: {{ index .Values.label 0 }}

The 0 selects the first element of the array.

A better option is to avoid using an array and replace it with a map:

label:
  foo:
    name: foo
    value: foo1
  bar:
    name: bar
    value: bar2

And you dont even need the index function:

foolabel: {{ .Values.label.foo }}