From f71a6b7f893be024e8bb3983fd14befa2616b8e4 Mon Sep 17 00:00:00 2001 From: Alexandre Carton Date: Wed, 8 Apr 2020 15:17:24 +0200 Subject: [PATCH] [elasticsearch] Add envFrom parameter --- elasticsearch/README.md | 1 + elasticsearch/templates/statefulset.yaml | 8 ++++++++ elasticsearch/tests/elasticsearch_test.py | 9 +++++++++ elasticsearch/values.yaml | 7 +++++++ 4 files changed, 25 insertions(+) diff --git a/elasticsearch/README.md b/elasticsearch/README.md index 6b380b57f..3fc9bdfe2 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -99,6 +99,7 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.6.2 | `esMajorVersion` | Used to set major version specific configuration. If you are using a custom image and not running the default Elasticsearch version you will need to set this to the version you are running (e.g. `esMajorVersion: 6`) | `""` | | `esConfig` | Allows you to add any config files in `/usr/share/elasticsearch/config/` such as `elasticsearch.yml` and `log4j2.properties`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/elasticsearch/values.yaml) for an example of the formatting. | `{}` | | `extraEnvs` | Extra [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config) which will be appended to the `env:` definition for the container | `[]` | +| `envFrom` | Templatable string of envFrom to be passed to the [environment from variables](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables) which will be appended to the `envFrom:` definition for the container | `[]` | | `extraVolumes` | Templatable string of additional volumes to be passed to the `tpl` function | `""` | | `extraVolumeMounts` | Templatable string of additional volumeMounts to be passed to the `tpl` function | `""` | | `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` | diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 31a6cec02..4430243a6 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -266,6 +266,10 @@ spec: {{- end }} {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 10 }} +{{- end }} +{{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} {{- end }} volumeMounts: {{- if .Values.persistence.enabled }} @@ -344,6 +348,10 @@ spec: {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 10 }} {{- end }} + {{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} + {{- end }} {{- end }} {{- end }} {{- if .Values.lifecycle }} diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 16d05c79f..535f05cff 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -283,6 +283,15 @@ def test_adding_extra_env_vars(): env = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]["env"] assert {"name": "hello", "value": "world"} in env +def test_adding_env_from(): + config = """ +envFrom: +- secretRef: + name: secret-name +""" + r = helm_template(config) + secretRef = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]["envFrom"][0]["secretRef"] + assert secretRef == {"name": "secret-name"} def test_adding_a_extra_volume_with_volume_mount(): config = """ diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 4486d53c2..5f251f5e2 100755 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -34,6 +34,13 @@ extraEnvs: [] # - name: MY_ENVIRONMENT_VAR # value: the_value_goes_here +# Allows you to load environment variables from kubernetes secret or config map +envFrom: [] +# - secretRef: +# name: env-secret +# - configMapRef: +# name: config-map + # A list of secrets and their paths to mount inside the pod # This is useful for mounting certificates for security and for mounting # the X-Pack license