I am trying to make an helm chart for my custom elk stack. I use the stable/elasticsearch-curator chart as a dependency.
In my values.yaml file, I use some env variables to pass the elasticsearch host:
esClusterName: &esClusterName "elasticsearch-logs"
...
elasticsearch-curator:
env:
ES_CLUSTER_NAME: *esClusterName
ELASTICSEARCH_HOST: $(ES_CLUSTER_NAME)-master
configMaps:
config_yml: |-
---
client:
hosts:
- ${ELASTICSEARCH_HOST}
port: 9200
But the variable is not correctly interpolated as shown by this error message:
HTTP N/A error: HTTPConnectionPool(host='$(es_cluster_name)-master', port=9200): Max retries exceeded with ...
Inside my pod, ELASTICSEARCH_HOST = '$(es_cluster_name)-master'
--a string of the name of my variable in LOWERCASE and "-master"-- instead of "elasticsearch-logs-master"
.
I cannot wrap my head arround this. I have used the same technique -- env variable interpolation -- for the other dependencies and it works.
The only difference I see is that the helm chart for elasticsearch-curator passes env variables differently from the other charts:
# stable/elasticsearch-curator/templates/cronjob.yaml
(The file is here)
env:
{{- if .Values.env }}
{{- range $key,$value := .Values.env }}
- name: {{ $key | upper | quote}}
value: {{ $value | quote}}
{{- end }}
{{- end }}
And this template expects the values to be passed in values.yaml like so: ( the file is here)
env:
MY_ENV_VAR: value1
MY_OTHER_VAR: value2
whereas all other templates use this way: ( exemple file)
env: {{ toYaml .Values.extraEnvs | nindent 10 }}
with a values.yaml like so: ( exemple file)
extraEnvs:
- name: MY_ENVIRONMENT_VAR
value: the_value_goes_here
But I'm not sure if this difference explains my problem. So my question is: how do I make it work?