From 85a2f2f6ef72dd6172c52c4765835a437b54405f Mon Sep 17 00:00:00 2001 From: cartonalexandre Date: Tue, 7 Apr 2020 17:25:12 +0200 Subject: [PATCH 1/4] [logstash] Add envFrom parameter --- logstash/README.md | 1 + logstash/templates/statefulset.yaml | 4 ++++ logstash/tests/logstash_test.py | 13 +++++++++++++ logstash/values.yaml | 7 +++++++ 4 files changed, 25 insertions(+) diff --git a/logstash/README.md b/logstash/README.md index c2db20a32..e0e6af05f 100644 --- a/logstash/README.md +++ b/logstash/README.md @@ -65,6 +65,7 @@ helm install --name logstash elastic/logstash --set imageTag=7.6.2 | `antiAffinityTopologyKey` | The [anti-affinity topology key](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity). By default this will prevent multiple Logstash nodes from running on the same Kubernetes node | `kubernetes.io/hostname` | | `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` | | `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 | `[]` | | `extraInitContainers` | Templatable string of additional init containers to be passed to the `tpl` function | `""` | | `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 | `""` | diff --git a/logstash/templates/statefulset.yaml b/logstash/templates/statefulset.yaml index 6c9838d3a..30dbb062f 100644 --- a/logstash/templates/statefulset.yaml +++ b/logstash/templates/statefulset.yaml @@ -160,6 +160,10 @@ spec: value: "{{ .Values.logstashJavaOpts }}" {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 10 }} +{{- end }} +{{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} {{- end }} volumeMounts: {{- if .Values.persistence.enabled }} diff --git a/logstash/tests/logstash_test.py b/logstash/tests/logstash_test.py index ed798a496..55d838c1b 100755 --- a/logstash/tests/logstash_test.py +++ b/logstash/tests/logstash_test.py @@ -141,6 +141,19 @@ def test_adding_extra_env_vars(): 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"][name]["spec"]["template"]["spec"]["containers"][0][ + "envFrom" + ][0]["secretRef"] + assert secretRef == {"name": "secret-name"} + + def test_adding_a_extra_volume_with_volume_mount(): config = """ extraVolumes: | diff --git a/logstash/values.yaml b/logstash/values.yaml index 412252510..fc1b544ef 100755 --- a/logstash/values.yaml +++ b/logstash/values.yaml @@ -29,6 +29,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 secretMounts: [] From cdf5cb00fa184b28510a19c30c5924671ae075a4 Mon Sep 17 00:00:00 2001 From: Alexandre Carton Date: Tue, 21 Apr 2020 23:39:48 +0200 Subject: [PATCH 2/4] [elasticsearch] Add envFrom parameter --- elasticsearch/README.md | 1 + elasticsearch/templates/statefulset.yaml | 9 +++++++++ elasticsearch/tests/elasticsearch_test.py | 13 +++++++++++++ elasticsearch/values.yaml | 7 +++++++ 4 files changed, 30 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..75a48337c 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -173,6 +173,7 @@ spec: cp -a /usr/share/elasticsearch/config/elasticsearch.keystore /tmp/keystore/ env: {{ toYaml .Values.extraEnvs | nindent 10 }} + envFrom: {{ toYaml .Values.envFrom | nindent 10 }} resources: {{ toYaml .Values.initResources | nindent 10 }} volumeMounts: - name: keystore @@ -266,6 +267,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 +349,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..0bbf2839e 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -284,6 +284,19 @@ def test_adding_extra_env_vars(): 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 = """ extraVolumes: | 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 From ab01c8541db27c828033eb7b4305a2f8fbe49c5b Mon Sep 17 00:00:00 2001 From: Alexandre Carton Date: Tue, 21 Apr 2020 23:40:49 +0200 Subject: [PATCH 3/4] [kibana] Add envFrom parameter --- kibana/README.md | 1 + kibana/templates/deployment.yaml | 4 ++++ kibana/tests/kibana_test.py | 13 +++++++++++++ kibana/values.yaml | 7 +++++++ 4 files changed, 25 insertions(+) diff --git a/kibana/README.md b/kibana/README.md index 0fd5aac95..606edcd1a 100644 --- a/kibana/README.md +++ b/kibana/README.md @@ -57,6 +57,7 @@ helm install --name kibana elastic/kibana --set imageTag=7.6.2 | `elasticsearchURL` | The URL used to connect to Elasticsearch. Deprecated, needs to be used for Kibana versions < 6.6 | | | `replicas` | Kubernetes replica count for the deployment (i.e. how many pods) | `1` | | `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 | `name: NODE_OPTIONS`
`value: "--max-old-space-size=1800"` | +| `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 | `[]` | | `secretMounts` | Allows you easily mount a secret as a file inside the deployment. Useful for mounting certificates and other secrets. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/kibana/values.yaml) for an example | `[]` | | `image` | The Kibana docker image | `docker.elastic.co/kibana/kibana` | | `imageTag` | The Kibana docker image tag | `7.6.2` | diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml index b7a97758e..aca2ee153 100644 --- a/kibana/templates/deployment.yaml +++ b/kibana/templates/deployment.yaml @@ -90,6 +90,10 @@ spec: value: "{{ .Values.serverHost }}" {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 10 }} +{{- end }} +{{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} {{- end }} readinessProbe: {{ toYaml .Values.readinessProbe | indent 10 }} diff --git a/kibana/tests/kibana_test.py b/kibana/tests/kibana_test.py index 4b864f2f0..1341c6146 100644 --- a/kibana/tests/kibana_test.py +++ b/kibana/tests/kibana_test.py @@ -89,6 +89,19 @@ def test_overriding_the_port(): assert r["service"][name]["spec"]["ports"][0]["targetPort"] == 5602 +def test_adding_env_from(): + config = """ +envFrom: +- secretRef: + name: secret-name +""" + r = helm_template(config) + secretRef = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0][ + "envFrom" + ][0]["secretRef"] + assert secretRef == {"name": "secret-name"} + + def test_adding_image_pull_secrets(): config = """ imagePullSecrets: diff --git a/kibana/values.yaml b/kibana/values.yaml index 468a98533..185a98377 100755 --- a/kibana/values.yaml +++ b/kibana/values.yaml @@ -14,6 +14,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 From 289ffb3431ee2046cdd2a0022467b1f47c6a3f47 Mon Sep 17 00:00:00 2001 From: Alexandre Carton Date: Tue, 21 Apr 2020 23:41:21 +0200 Subject: [PATCH 4/4] [apm-server] Add envFrom parameter --- apm-server/README.md | 1 + apm-server/templates/deployment.yaml | 4 ++++ apm-server/tests/apmserver_test.py | 13 +++++++++++++ apm-server/values.yaml | 7 +++++++ 4 files changed, 25 insertions(+) diff --git a/apm-server/README.md b/apm-server/README.md index 8e2e9381f..6040cca68 100644 --- a/apm-server/README.md +++ b/apm-server/README.md @@ -69,6 +69,7 @@ helm install --name apm-server elastic/apm-server --set imageTag=7.6.2 | `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` | | `extraInitContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` | | `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 | `[]` | | `extraVolumeMounts` | List of additional volumeMounts | `[]` | | `extraVolumes` | List of additional volumes | `[]` | | `image` | The APM Server docker image | `docker.elastic.co/apm/apm-server` | diff --git a/apm-server/templates/deployment.yaml b/apm-server/templates/deployment.yaml index fa740b32c..87a1bc085 100644 --- a/apm-server/templates/deployment.yaml +++ b/apm-server/templates/deployment.yaml @@ -79,6 +79,10 @@ spec: env: {{ toYaml . | nindent 10 }} {{- end }} + {{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} + {{- end }} {{- if .Values.podSecurityContext }} securityContext: {{ toYaml .Values.podSecurityContext | indent 10 }} diff --git a/apm-server/tests/apmserver_test.py b/apm-server/tests/apmserver_test.py index 2ed716433..cb89d880e 100644 --- a/apm-server/tests/apmserver_test.py +++ b/apm-server/tests/apmserver_test.py @@ -72,6 +72,19 @@ def test_adding_envs(): assert {"name": "LOG_LEVEL", "value": "DEBUG"} in envs +def test_adding_env_from(): + config = """ +envFrom: +- secretRef: + name: secret-name +""" + r = helm_template(config) + secretRef = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0][ + "envFrom" + ][0]["secretRef"] + assert secretRef == {"name": "secret-name"} + + def test_adding_image_pull_secrets(): config = """ imagePullSecrets: diff --git a/apm-server/values.yaml b/apm-server/values.yaml index f1af513ee..2b198dbbb 100755 --- a/apm-server/values.yaml +++ b/apm-server/values.yaml @@ -45,6 +45,13 @@ extraEnvs: [] # name: elastic-credentials # key: password +# Allows you to load environment variables from kubernetes secret or config map +envFrom: [] +# - secretRef: +# name: env-secret +# - configMapRef: +# name: config-map + extraVolumeMounts: [] # - name: extras # mountPath: /usr/share/extras