Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request elastic#569 from cartonalexandre/master
Browse files Browse the repository at this point in the history
Added support for envFrom in apm-server, logstash, kibana and elasticsearch
  • Loading branch information
jmlrt committed Apr 23, 2020
1 parent ac520df commit e2d4b9c
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 33 deletions.
1 change: 1 addition & 0 deletions apm-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ This chart is tested with the latest 7.7.0-SNAPSHOT versions.
| `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` |
Expand Down
4 changes: 4 additions & 0 deletions apm-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
13 changes: 13 additions & 0 deletions apm-server/tests/apmserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions apm-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ This chart is tested with the latest 7.7.0-SNAPSHOT versions.
| `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/7.7/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 | `[]` |
Expand Down
9 changes: 9 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,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
Expand Down Expand Up @@ -291,6 +292,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 }}
Expand Down Expand Up @@ -376,6 +381,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 }}
Expand Down
13 changes: 13 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,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: |
Expand Down
7 changes: 7 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit e2d4b9c

Please sign in to comment.