How to access dotted variable in values.yaml helm chart

2/20/2019

Could you please help me how to access: database password in helm chart?

I tried this: "{{ .Values "grafana.ini" database.name }}"

and many other modifications however, non of these worked for me.

grafana.ini:
  paths:
    data: /var/lib/grafana/data
    logs: /var/log/grafana
    plugins: /var/lib/grafana/plugins
  analytics:
    check_for_updates: true
  log:
    mode: console
  grafana_net:
    url: https://grafana.net
  server:


  database:
    type: postgres
    host: "127.0.0.1"
    name: name
    user: myuser
    password: pass
-- user2156115
kubernetes-helm

1 Answer

2/20/2019

Here is the answer:

  initContainers:
    - name: init
      image: init:v0.0.1
      env:
      - name: DB_NAME
        value: {{ (index .Values "grafana.ini" "database" "name" ) }}
      - name: DB_USER
        value: {{ (index .Values "grafana.ini" "database" "user" ) }}
      - name: DB_PASS
        value: {{ (index .Values "grafana.ini" "database" "password" ) }}
      - name: SERVICE_DB_USER
        value: "{{ .Values.serviceDbUser }}"
      - name: REAL_DB_HOST
        value: "{{ .Values.realDbHost }}"
      - name: SERVICE_DB_PASS
        value: "{{ .Values.serviceDbPass }}"

I got this from official slack kubernetes channel.

Hope it will help the others.

-- user2156115
Source: StackOverflow