diff --git a/filebeat/README.md b/filebeat/README.md index e8a7ebbef..4a32a1151 100644 --- a/filebeat/README.md +++ b/filebeat/README.md @@ -60,8 +60,9 @@ helm install --name filebeat elastic/filebeat --set imageTag=7.5.1 | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | | `filebeatConfig` | Allows you to add any config files in `/usr/share/filebeat` such as `filebeat.yml`. See [values.yaml](./values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](./values.yaml) | | `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 | `[]` | -| `extraVolumeMounts` | List of additional volumeMounts to be mounted on the Daemonset | `""` | -| `extraVolumes` | List of additional volumes to be mounted on the Daemonset | `""` | +| `extraVolumeMounts` | List of additional volumeMounts to be mounted on the Daemonset | `""` | +| `extraVolumes` | List of additional volumes to be mounted on the Daemonset | `""` | +| `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 | `[]` | `hostPathRoot` | Fully-qualified [hostPath](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that will be used to persist Filebeat registry data | `/var/lib` | | `hostNetworking` | Use host networking in the daemonset so that hostname is reported correctly | `false` | | `image` | The Filebeat docker image | `docker.elastic.co/beats/filebeat` | diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index 3168fafb7..7b81f644c 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -125,6 +125,10 @@ spec: {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 8 }} {{- end }} +{{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} +{{- end }} {{- if .Values.podSecurityContext }} securityContext: {{ toYaml .Values.podSecurityContext | indent 10 }} diff --git a/filebeat/tests/filebeat_test.py b/filebeat/tests/filebeat_test.py index aa4518955..02adb2eff 100644 --- a/filebeat/tests/filebeat_test.py +++ b/filebeat/tests/filebeat_test.py @@ -246,6 +246,16 @@ def test_priority_class_name(): priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName'] assert priority_class_name == "highest" +def test_adding_env_from(): + config = ''' +envFrom: +- configMapRef: + name: configmap-name +''' + r = helm_template(config) + configMapRef = r['daemonset'][name]['spec']['template']['spec']['containers'][0]['envFrom'][0]['configMapRef'] + assert configMapRef == {'name': 'configmap-name'} + def test_setting_fullnameOverride(): config = ''' fullnameOverride: 'filebeat-custom' diff --git a/filebeat/values.yaml b/filebeat/values.yaml index b1f2d941b..893946043 100755 --- a/filebeat/values.yaml +++ b/filebeat/values.yaml @@ -30,6 +30,10 @@ extraVolumes: [] # - name: extras # emptyDir: {} +envFrom: [] +# - configMapRef: +# name: configmap-name + # Root directory where Filebeat will write data to in order to persist registry data across pod restarts (file position and other metadata). hostPathRoot: /var/lib hostNetworking: false diff --git a/metricbeat/README.md b/metricbeat/README.md index de295973b..7ee006b73 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -71,6 +71,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.5.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 | `[]` | | `extraVolumeMounts` | Templatable string of additional volumeMounts to be passed to the `tpl` function | `""` | | `extraVolumes` | Templatable string of additional volumes to be passed to the `tpl` function | `""` | +| `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 | `[]` | `hostPathRoot` | Fully-qualified [hostPath](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that will be used to persist Metricbeat registry data | `/var/lib` | | `image` | The Metricbeat docker image | `docker.elastic.co/beats/metricbeat` | | `imageTag` | The Metricbeat docker image tag | `7.5.1` | diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 6bc6441e3..573727896 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -124,6 +124,10 @@ spec: {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 8 }} {{- end }} +{{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} +{{- end }} {{- if .Values.podSecurityContext }} securityContext: {{ toYaml .Values.podSecurityContext | indent 10 }} diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index 69ae29573..292afe71d 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -96,6 +96,10 @@ spec: {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 8 }} {{- end }} +{{- if .Values.envFrom }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} +{{- end }} {{- if .Values.podSecurityContext }} securityContext: {{ toYaml .Values.podSecurityContext | indent 10 }} diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index 6aec2c22e..c3c693033 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -240,6 +240,16 @@ def test_adding_pod_labels(): assert r['daemonset'][name]['metadata']['labels']['app.kubernetes.io/name'] == 'metricbeat' assert r['daemonset'][name]['spec']['template']['metadata']['labels']['app.kubernetes.io/name'] == 'metricbeat' +def test_adding_env_from(): + config = ''' +envFrom: +- configMapRef: + name: configmap-name +''' + r = helm_template(config) + configMapRef = r['daemonset'][name]['spec']['template']['spec']['containers'][0]['envFrom'][0]['configMapRef'] + assert configMapRef == {'name': 'configmap-name'} + def test_setting_fullnameOverride(): config = ''' fullnameOverride: 'metricbeat-custom' diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index 4e8b501f6..2d1100039 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -82,6 +82,10 @@ extraVolumes: [] # - name: extras # emptyDir: {} +envFrom: [] + # - configMapRef: + # name: config-secret + # Root directory where metricbeat will write data to in order to persist registry data across pod restarts (file position and other metadata). hostPathRoot: /var/lib