Grafana helm chart fails to install when defining env
There appears to be some default environment variables configured that get destroyed when declaring an environment variable under env: {}.
As per the docs at https://grafana.com/docs/grafana/latest/alerting/high-availability/enable-alerting-ha/#update-kubernetes-container-definition it recommends to use the pod's IP address passed as an environment variable. When doing this I get the following error:
Error: template: grafana/templates/secret.yaml:1:62: executing "grafana/templates/secret.yaml" at <.Values.env.GF_SECURITY_ADMIN_PASSWORD__FILE>: can't evaluate field GF_SECURITY_ADMIN_PASSWORD__FILE in type interface {}
If I do not change the values from env: {} it installs fine.
For now I am trying to see if the deployment will work properly for ha alerting without passing the pod IP (using the default value of 0.0.0.0)
Same issue on any addition of env variables, chart is unusable in this state
If you want env from fieldRef then you should use envValueFrom instead of env.
Like values.yaml
envValueFrom:
POD_IP:
fieldRef:
fieldPath: status.podIP
will be rendered as
- name: "POD_IP"
valueFrom:
fieldRef:
fieldPath: status.podIP
So after much pain I finally noticed that env: {} (Note the {}) is a MAPPING, not an array.
So if trying to do:
env:
- name: FOO
value: bar
you will run into this error. The chart templates the mapping instead of just including it, violating convention of most other charts (not just including the array like most that use env: [].
But seems like have to do:
env:
FOO: bar
The values.yaml really could use a shorter comment calling this out - I do not seem to be the only one who lost time to this.
@MaxCWhitehead I was trying to do this
grafana:
env:
FOO: bar
but after doing helm template . got this
- name: "FOO"
value: "bar"
it looks like every env variable name will be a string
https://github.com/grafana/helm-charts/blob/72a7caf12f61cd5e7d82acbe586fb1e9c0bce2f6/charts/grafana/templates/_pod.tpl#L1200
any suggestions