Helm Chart - Can't evaluate .Release.Name in a field

4/28/2020

I am new to Helm and I can not understand why this is happening. I am using the official EFK chart and I am trying to add release name to fluentd-elasticsearch's host fields but it does not get evaluated. It is passed just as a string. The release name in ELASTICSEARCH_HOSTS is evaluated properly but the same in host field is not evaluated at all. Can anyone tell why is this happening and how to fix it?

# Default values for elk.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
elasticsearch:
  enabled: true
kibana:
  enabled: true
  env:
    ELASTICSEARCH_HOSTS: 'http://{{ .Release.Name }}-elasticsearch-client:9200'
logstash:
  enabled: false
filebeat:
  enabled: false
fluentd:
  enabled: false
fluent-bit:
  enabled: false
fluentd-elasticsearch:
  enabled: true
  elasticsearch:
    host: '{{ .Release.Name }}-elasticsearch-client'
nginx-ldapauth-proxy:
  enabled: false
elasticsearch-curator:
  enabled: false
elasticsearch-exporter:
  enabled: false

Helm version: version.BuildInfo{Version:"v3.1.0-rc.3", GitCommit:"b29d20baf09943e134c2fa5e1e1cab3bf93315fa", GitTreeState:"clean", GoVersion:"go1.13.7"}

-- aliench0
kubernetes
kubernetes-helm

1 Answer

4/29/2020

The values.yaml file is not evaluated. So you cannot use {{ .Release.Name }} inside values.yaml.

The reason why it works for ELASTICSEARCH_HOSTS is that inside Kibana Helm Chart, the values are first kind-of copied and later evaluated.

-- RafaƂ Leszko
Source: StackOverflow