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..9aa15d845 100644 --- a/apm-server/tests/apmserver_test.py +++ b/apm-server/tests/apmserver_test.py @@ -71,6 +71,15 @@ def test_adding_envs(): envs = r["deployment"][name]["spec"]["template"]["spec"]["containers"][0]["env"] 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 = """ 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