From fbf62494ff211cbbbfdf8210ba20d298ba6f4150 Mon Sep 17 00:00:00 2001 From: Vasilis Remmas Date: Wed, 29 Jan 2020 14:51:21 +0100 Subject: [PATCH 1/2] Add extraInitContainers to filebeat chart --- filebeat/README.md | 1 + filebeat/templates/daemonset.yaml | 4 ++++ filebeat/values.yaml | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/filebeat/README.md b/filebeat/README.md index 702984ea4..1655a2b87 100644 --- a/filebeat/README.md +++ b/filebeat/README.md @@ -60,6 +60,7 @@ helm install --name filebeat elastic/filebeat --set imageTag=7.5.2 | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | `filebeatConfig` | Allows you to add any config files in `/usr/share/filebeat` such as `filebeat.yml`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/filebeat/values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](https://github.com/elastic/helm-charts/tree/master/filebeat/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 | `[]` | +| `extraInitContainers` | List of additional init containers to be added at 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 | `[]` | diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index 207b0fa8a..0132cb2f5 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -84,6 +84,10 @@ spec: {{- if .Values.imagePullSecrets }} imagePullSecrets: {{ toYaml .Values.imagePullSecrets | indent 8 }} + {{- end }} + {{- if .Values.extraInitContainers }} + initContainers: +{{ toYaml .Values.extraInitContainers | indent 8 }} {{- end }} containers: - name: "filebeat" diff --git a/filebeat/values.yaml b/filebeat/values.yaml index 6cce7feb5..548d72650 100755 --- a/filebeat/values.yaml +++ b/filebeat/values.yaml @@ -30,6 +30,11 @@ extraVolumes: [] # - name: extras # emptyDir: {} +extraInitContainers: [] +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + envFrom: [] # - configMapRef: # name: configmap-name From f114e2af7855c14fdf2adf5241855b2c8ebb0d69 Mon Sep 17 00:00:00 2001 From: Vasilis Remmas Date: Thu, 30 Jan 2020 09:28:40 +0100 Subject: [PATCH 2/2] Add tests for extraInitContainers to filebeat chart --- filebeat/tests/filebeat_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/filebeat/tests/filebeat_test.py b/filebeat/tests/filebeat_test.py index 02adb2eff..30067937f 100644 --- a/filebeat/tests/filebeat_test.py +++ b/filebeat/tests/filebeat_test.py @@ -54,6 +54,17 @@ def test_adding_envs(): envs = r['daemonset'][name]['spec']['template']['spec']['containers'][0]['env'] assert {'name': 'LOG_LEVEL', 'value': 'DEBUG'} in envs +def test_adding_init_containers(): + config = ''' +extraInitContainers: +- name: dummy-init + image: busybox + command: ['echo', 'hey'] +''' + r = helm_template(config) + initContainers = r['daemonset'][name]['spec']['template']['spec']['initContainers'] + assert {'name': 'dummy-init', 'image': 'busybox', 'command': ['echo', 'hey']} in initContainers + def test_adding_image_pull_secrets(): config = '''