From 4b1d262237a06a275c485cf3026d2ed9e8141dc8 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 15:03:53 +0100 Subject: [PATCH 01/11] [elasticsearch] add extracontainers --- elasticsearch/README.md | 3 ++- elasticsearch/templates/statefulset.yaml | 3 +++ elasticsearch/tests/elasticsearch_test.py | 12 ++++++++++++ elasticsearch/values.yaml | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/elasticsearch/README.md b/elasticsearch/README.md index d181fcbe6..62a315181 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -80,6 +80,7 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.5.2 | `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 | `[]` | | `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 | `""` | | `extraInitContainers` | Templatable string of additional init containers to be passed to the `tpl` function | `""` | | `secretMounts` | Allows you easily mount a secret as a file inside the statefulset. Useful for mounting certificates and other secrets. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/elasticsearch/values.yaml) for an example | `[]` | | `image` | The Elasticsearch docker image | `docker.elastic.co/elasticsearch/elasticsearch` | @@ -88,7 +89,7 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.5.2 | `podAnnotations` | Configurable [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) applied to all Elasticsearch pods | `{}` | | `labels` | Configurable [label](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) applied to all Elasticsearch pods | `{}` | | `esJavaOpts` | [Java options](https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html) for Elasticsearch. This is where you should configure the [jvm heap size](https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html) | `-Xmx1g -Xms1g` | -| `resources` | Allows you to set the [resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the statefulset | `requests.cpu: 1000m`
`requests.memory: 2Gi`
`limits.cpu: 1000m`
`limits.memory: 2Gi` | +| `resources` | Allows you to set the [resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the statefulset | `requests.cpu: 1000m`
`requests.memory: 2Gi`
`limits.cpu: 1000m`
`limits.memory: 2Gi` | | `initResources` | Allows you to set the [resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the initContainer in the statefulset | {} | | `sidecarResources` | Allows you to set the [resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the sidecar containers in the statefulset | {} | | `networkHost` | Value for the [network.host Elasticsearch setting](https://www.elastic.co/guide/en/elasticsearch/reference/current/network.host.html) | `0.0.0.0` | diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index a47a85fec..c2a63fb79 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -350,3 +350,6 @@ spec: lifecycle: {{ toYaml .Values.lifecycle | indent 10 }} {{- end }} + {{- if .Values.extraContainers }} +{{ tpl .Values.extraContainers . | indent 6 }} + {{- end }} \ No newline at end of file diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 7e2f0c112..a6a879cc5 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -326,6 +326,18 @@ def test_adding_a_extra_volume_with_volume_mount(): assert {'name': 'extras', 'mountPath': '/usr/share/extras', 'readOnly': True} in extraVolumeMounts +def test_adding_a_extra_container(): + config = ''' +extraContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraContainer = r['statefulset'][uname]['spec']['template']['spec']['containers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainer + + def test_adding_a_extra_init_container(): config = ''' extraInitContainers: | diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 46c798a30..e7e17fa45 100755 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -121,6 +121,11 @@ extraVolumeMounts: "" # mountPath: /usr/share/extras # readOnly: true +extraContainers: "" + # - name: do-something + # image: busybox + # command: ['do', 'something'] + extraInitContainers: "" # - name: do-something # image: busybox From c5b14fbfa80e1e40ee46f1a9e42ac7865b8c023b Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 15:07:30 +0100 Subject: [PATCH 02/11] [filebeat] add extracontainers --- filebeat/README.md | 1 + filebeat/templates/daemonset.yaml | 3 +++ filebeat/tests/filebeat_test.py | 13 +++++++++++++ filebeat/values.yaml | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/filebeat/README.md b/filebeat/README.md index 1655a2b87..e727d570c 100644 --- a/filebeat/README.md +++ b/filebeat/README.md @@ -59,6 +59,7 @@ helm install --name filebeat elastic/filebeat --set imageTag=7.5.2 | Parameter | Description | Default | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | `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) | +| `extraContainers` | List of additional init containers to be added at the Daemonset | `""` | | `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 | `[]` | diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index 0132cb2f5..d2f5a234f 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -150,3 +150,6 @@ spec: {{- if .Values.extraVolumeMounts }} {{ toYaml .Values.extraVolumeMounts | indent 8 }} {{- end }} + {{- if .Values.extraContainers }} +{{ tpl .Values.extraContainers . | indent 6 }} + {{- end }} diff --git a/filebeat/tests/filebeat_test.py b/filebeat/tests/filebeat_test.py index 30067937f..c4d401b48 100644 --- a/filebeat/tests/filebeat_test.py +++ b/filebeat/tests/filebeat_test.py @@ -54,6 +54,19 @@ 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_a_extra_container(): + config = ''' +extraContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraContainer = r['daemonset'][name]['spec']['template']['spec']['containers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainer + + def test_adding_init_containers(): config = ''' extraInitContainers: diff --git a/filebeat/values.yaml b/filebeat/values.yaml index 548d72650..f0e802f7c 100755 --- a/filebeat/values.yaml +++ b/filebeat/values.yaml @@ -30,6 +30,11 @@ extraVolumes: [] # - name: extras # emptyDir: {} +extraContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + extraInitContainers: [] # - name: dummy-init # image: busybox From 5debd6ad3fca2eb85913a0b9fd98616b3cce7c07 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 15:11:27 +0100 Subject: [PATCH 03/11] [kibana] add extracontainers --- kibana/README.md | 1 + kibana/templates/deployment.yaml | 3 +++ kibana/tests/kibana_test.py | 12 ++++++++++++ kibana/values.yaml | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/kibana/README.md b/kibana/README.md index c013ba972..0208ee3d6 100644 --- a/kibana/README.md +++ b/kibana/README.md @@ -82,6 +82,7 @@ helm install --name kibana elastic/kibana --set imageTag=7.5.2 | `labels` | Configurable [label](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) applied to all Kibana pods | `{}` | | `lifecycle` | Allows you to add lifecycle configuration. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/kibana/values.yaml) for an example of the formatting. | `{}` | | `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` | +| `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` | ## Examples diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml index d2bf9e783..49a2b7f93 100644 --- a/kibana/templates/deployment.yaml +++ b/kibana/templates/deployment.yaml @@ -134,3 +134,6 @@ spec: mountPath: /usr/share/kibana/config/{{ $path }} subPath: {{ $path }} {{- end -}} + {{- if .Values.extraContainers }} +{{ tpl .Values.extraContainers . | indent 6 }} + {{- end }} \ No newline at end of file diff --git a/kibana/tests/kibana_test.py b/kibana/tests/kibana_test.py index 8a8103865..179a9f3cc 100644 --- a/kibana/tests/kibana_test.py +++ b/kibana/tests/kibana_test.py @@ -136,6 +136,18 @@ def test_adding_an_affinity_rule(): 'requiredDuringSchedulingIgnoredDuringExecution'][0]['topologyKey'] == 'kubernetes.io/hostname' +def test_adding_a_extra_container(): + config = ''' +extraContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraContainer = r['deployment'][name]['spec']['template']['spec']['containers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainer + + def test_adding_an_ingress_rule(): config = ''' ingress: diff --git a/kibana/values.yaml b/kibana/values.yaml index f708013e3..cb394eb66 100755 --- a/kibana/values.yaml +++ b/kibana/values.yaml @@ -73,6 +73,11 @@ priorityClassName: "" httpPort: 5601 +extraContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + updateStrategy: type: "Recreate" From 5e297ad746aa322c375f59efd97b91c44c54b604 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 15:17:29 +0100 Subject: [PATCH 04/11] [metricbeat] add extracontainers --- metricbeat/README.md | 3 ++- metricbeat/templates/daemonset.yaml | 3 +++ metricbeat/templates/deployment.yaml | 3 +++ metricbeat/tests/metricbeat_test.py | 15 +++++++++++++++ metricbeat/values.yaml | 5 +++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/metricbeat/README.md b/metricbeat/README.md index 9c471798b..f7d05784f 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -68,10 +68,11 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.5.2 | Parameter | Description | Default | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | `metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/metricbeat/values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](https://github.com/elastic/helm-charts/tree/master/metricbeat/values.yaml) | +| `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 | `[]` | | `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 | `[]` +| `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.2` | diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 60917202e..93219c6b9 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -155,3 +155,6 @@ spec: {{- if .Values.extraVolumeMounts }} {{ toYaml .Values.extraVolumeMounts | indent 8 }} {{- end }} + {{- if .Values.extraContainers }} +{{ tpl .Values.extraContainers . | indent 6 }} + {{- end }} \ No newline at end of file diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index d1203427a..eb0f4e9bc 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -111,3 +111,6 @@ spec: {{- if .Values.extraVolumeMounts }} {{ toYaml .Values.extraVolumeMounts | indent 8 }} {{- end }} + {{- if .Values.extraContainers }} +{{ tpl .Values.extraContainers . | indent 6 }} + {{- end }} \ No newline at end of file diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index db3022d8c..acd3173dc 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -43,6 +43,21 @@ def test_defaults(): } in volumes +def test_adding_a_extra_container(): + config = ''' +extraContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraContainerDaemonset = r['daemonset'][name]['spec']['template']['spec']['containers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainerDaemonset + deployment_name = name + '-metrics' + extraContainerDeployment = r['deployment'][deployment_name]['spec']['template']['spec']['containers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainerDeployment + + def test_adding_envs(): config = ''' extraEnvs: diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index 4e34369ef..3b9e52a50 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -64,6 +64,11 @@ metricbeatConfig: replicas: 1 +extraContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + # Extra environment variables to append to the DaemonSet pod spec. # This will be appended to the current 'env:' key. You can use any of the kubernetes env # syntax here From 905d4da40ae86b9f628bf7593ec75b366e81ce13 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 15:20:27 +0100 Subject: [PATCH 05/11] [apm-server] add extracontainers --- apm-server/README.md | 1 + apm-server/templates/deployment.yaml | 3 +++ apm-server/tests/apmserver_test.py | 12 ++++++++++++ apm-server/values.yaml | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/apm-server/README.md b/apm-server/README.md index a1346c289..8e80f014b 100644 --- a/apm-server/README.md +++ b/apm-server/README.md @@ -66,6 +66,7 @@ helm install --name apm-server elastic/apm-server --set imageTag=7.5.2 | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | | `apmConfig` | Allows you to add any config files in `/usr/share/apm-server/config` such as `apm-server.yml`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/apm-server/values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](https://github.com/elastic/helm-charts/tree/master/apm-server/values.yaml) | | `replicas` | Number of APM servers to run | `1` | +| `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 | `[]` | | `extraVolumeMounts` | List of additional volumeMounts | `[]` | | `extraVolumes` | List of additional volumes | `[]` | diff --git a/apm-server/templates/deployment.yaml b/apm-server/templates/deployment.yaml index 1d0a269e6..365083648 100644 --- a/apm-server/templates/deployment.yaml +++ b/apm-server/templates/deployment.yaml @@ -115,3 +115,6 @@ spec: {{- if .Values.extraVolumes }} {{ toYaml .Values.extraVolumeMounts | indent 10 }} {{- end }} + {{- if .Values.extraContainers }} +{{ tpl .Values.extraContainers . | indent 6 }} + {{- end }} \ No newline at end of file diff --git a/apm-server/tests/apmserver_test.py b/apm-server/tests/apmserver_test.py index 250c13924..cda2c1b71 100644 --- a/apm-server/tests/apmserver_test.py +++ b/apm-server/tests/apmserver_test.py @@ -26,6 +26,18 @@ def test_defaults(): assert c['ports'][0]['containerPort'] == 8200 +def test_adding_a_extra_container(): + config = ''' +extraContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraContainer = r['deployment'][name]['spec']['template']['spec']['containers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainer + + def test_adding_envs(): config = ''' extraEnvs: diff --git a/apm-server/values.yaml b/apm-server/values.yaml index 187454bf7..490e4f45c 100755 --- a/apm-server/values.yaml +++ b/apm-server/values.yaml @@ -20,6 +20,11 @@ apmConfig: replicas: 1 +extraContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + # Extra environment variables to append to the DaemonSet pod spec. # This will be appended to the current 'env:' key. You can use any of the kubernetes env # syntax here From 690d626827c7bb915db6874afbc9043f89fc3337 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 18:41:56 +0100 Subject: [PATCH 06/11] [apm-server] add empty value to node port --- apm-server/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-server/values.yaml b/apm-server/values.yaml index 490e4f45c..97a7ccdaa 100755 --- a/apm-server/values.yaml +++ b/apm-server/values.yaml @@ -135,7 +135,7 @@ ingress: service: type: ClusterIP port: 8200 - nodePort: + nodePort: "" annotations: {} # cloud.google.com/load-balancer-type: "Internal" # service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0 From 44107248af58cdda8107d53d38415f39b8c63d53 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 18:42:24 +0100 Subject: [PATCH 07/11] [logstash] remove duplicate line --- logstash/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/logstash/README.md b/logstash/README.md index ba46512df..f10280c94 100644 --- a/logstash/README.md +++ b/logstash/README.md @@ -72,7 +72,6 @@ helm install --name logstash elastic/logstash --set imageTag=7.5.2 | `imagePullPolicy` | The Kubernetes [imagePullPolicy](https://kubernetes.io/docs/concepts/containers/images/#updating-images) value | `IfNotPresent` | | `imagePullSecrets` | Configuration for [imagePullSecrets](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-pod-that-uses-your-secret) so that you can use a private registry for your image | `[]` | | `imageTag` | The Logstash docker image tag | `7.5.2` | -| `extraInitContainers` | Templatable string of additional init containers to be passed to the `tpl` function | `""` | | `httpPort` | The http port that Kubernetes will use for the healthchecks and the service. | `9600` | | `labels` | Configurable [labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) applied to all Logstash pods | `{}` | | `lifecycle` | Allows you to add lifecycle configuration. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/logstash/values.yaml) for an example of the formatting. | `{}` | From 8ea88ae90cb467b4a64936221f83271eaf8e01e4 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 18:47:01 +0100 Subject: [PATCH 08/11] [apm-server] add extra init container --- apm-server/README.md | 1 + apm-server/templates/deployment.yaml | 4 ++++ apm-server/tests/apmserver_test.py | 12 ++++++++++++ apm-server/values.yaml | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/apm-server/README.md b/apm-server/README.md index 8e80f014b..5e9902b6d 100644 --- a/apm-server/README.md +++ b/apm-server/README.md @@ -67,6 +67,7 @@ helm install --name apm-server elastic/apm-server --set imageTag=7.5.2 | `apmConfig` | Allows you to add any config files in `/usr/share/apm-server/config` such as `apm-server.yml`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/apm-server/values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](https://github.com/elastic/helm-charts/tree/master/apm-server/values.yaml) | | `replicas` | Number of APM servers to run | `1` | | `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 | `[]` | | `extraVolumeMounts` | List of additional volumeMounts | `[]` | | `extraVolumes` | List of additional volumes | `[]` | diff --git a/apm-server/templates/deployment.yaml b/apm-server/templates/deployment.yaml index 365083648..fa740b32c 100644 --- a/apm-server/templates/deployment.yaml +++ b/apm-server/templates/deployment.yaml @@ -67,6 +67,10 @@ spec: imagePullSecrets: {{ toYaml .Values.imagePullSecrets | indent 8 }} {{- end }} + {{- if .Values.extraInitContainers }} + initContainers: +{{ tpl .Values.extraInitContainers . | indent 6 }} + {{- end }} containers: - name: apm-server image: "{{ .Values.image }}:{{ .Values.imageTag }}" diff --git a/apm-server/tests/apmserver_test.py b/apm-server/tests/apmserver_test.py index cda2c1b71..4f30b3b91 100644 --- a/apm-server/tests/apmserver_test.py +++ b/apm-server/tests/apmserver_test.py @@ -38,6 +38,18 @@ def test_adding_a_extra_container(): assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainer +def test_adding_a_extra_init_container(): + config = ''' +extraInitContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraInitContainer = r['deployment'][name]['spec']['template']['spec']['initContainers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraInitContainer + + def test_adding_envs(): config = ''' extraEnvs: diff --git a/apm-server/values.yaml b/apm-server/values.yaml index 97a7ccdaa..afc8fbf11 100755 --- a/apm-server/values.yaml +++ b/apm-server/values.yaml @@ -25,6 +25,11 @@ extraContainers: "" # image: busybox # command: ['echo', 'hey'] +extraInitContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + # Extra environment variables to append to the DaemonSet pod spec. # This will be appended to the current 'env:' key. You can use any of the kubernetes env # syntax here From decd945ef1a56aff0aacc7d6e2ffa9fadaf9d570 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 18:49:42 +0100 Subject: [PATCH 09/11] [kibana] add extra init containers --- kibana/README.md | 1 + kibana/templates/deployment.yaml | 4 ++++ kibana/tests/kibana_test.py | 12 ++++++++++++ kibana/values.yaml | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/kibana/README.md b/kibana/README.md index 0208ee3d6..cc819a5c3 100644 --- a/kibana/README.md +++ b/kibana/README.md @@ -83,6 +83,7 @@ helm install --name kibana elastic/kibana --set imageTag=7.5.2 | `lifecycle` | Allows you to add lifecycle configuration. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/kibana/values.yaml) for an example of the formatting. | `{}` | | `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` | | `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 | `""` | ## Examples diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml index 49a2b7f93..ad563b3f2 100644 --- a/kibana/templates/deployment.yaml +++ b/kibana/templates/deployment.yaml @@ -68,6 +68,10 @@ spec: imagePullSecrets: {{ toYaml .Values.imagePullSecrets | indent 8 }} {{- end }} + {{- if .Values.extraInitContainers }} + initContainers: +{{ tpl .Values.extraInitContainers . | indent 6 }} + {{- end }} containers: - name: kibana securityContext: diff --git a/kibana/tests/kibana_test.py b/kibana/tests/kibana_test.py index 179a9f3cc..1fb68a9b3 100644 --- a/kibana/tests/kibana_test.py +++ b/kibana/tests/kibana_test.py @@ -148,6 +148,18 @@ def test_adding_a_extra_container(): assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainer +def test_adding_a_extra_init_container(): + config = ''' +extraInitContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraInitContainer = r['deployment'][name]['spec']['template']['spec']['initContainers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraInitContainer + + def test_adding_an_ingress_rule(): config = ''' ingress: diff --git a/kibana/values.yaml b/kibana/values.yaml index cb394eb66..628336462 100755 --- a/kibana/values.yaml +++ b/kibana/values.yaml @@ -78,6 +78,11 @@ extraContainers: "" # image: busybox # command: ['echo', 'hey'] +extraInitContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + updateStrategy: type: "Recreate" From 219eea634d67e6238de1627c5dc272b9e4ea99a0 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 18:50:14 +0100 Subject: [PATCH 10/11] [kibana] fix typo --- kibana/tests/kibana_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kibana/tests/kibana_test.py b/kibana/tests/kibana_test.py index 1fb68a9b3..a6c1e3fed 100644 --- a/kibana/tests/kibana_test.py +++ b/kibana/tests/kibana_test.py @@ -331,7 +331,7 @@ def test_service_labels(): assert r['service'][name]['metadata']['labels']['label1'] == 'value1' -def test_service_annotatations(): +def test_service_annotations(): config = ''' service: annotations: From 3d482df987b98756d1876f9a701e9305b9f43378 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Thu, 6 Feb 2020 18:57:22 +0100 Subject: [PATCH 11/11] [metricbeat] add extra init containers --- metricbeat/README.md | 1 + metricbeat/templates/daemonset.yaml | 4 ++++ metricbeat/templates/deployment.yaml | 4 ++++ metricbeat/tests/metricbeat_test.py | 15 +++++++++++++++ metricbeat/values.yaml | 5 +++++ 5 files changed, 29 insertions(+) diff --git a/metricbeat/README.md b/metricbeat/README.md index f7d05784f..512e22a0e 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -69,6 +69,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.5.2 | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | `metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml`. See [values.yaml](https://github.com/elastic/helm-charts/tree/master/metricbeat/values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](https://github.com/elastic/helm-charts/tree/master/metricbeat/values.yaml) | | `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 | `[]` | | `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 | `""` | diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 93219c6b9..392b7cf84 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -86,6 +86,10 @@ spec: {{- if .Values.imagePullSecrets }} imagePullSecrets: {{ toYaml .Values.imagePullSecrets | indent 8 }} + {{- end }} + {{- if .Values.extraInitContainers }} + initContainers: +{{ tpl .Values.extraInitContainers . | indent 6 }} {{- end }} containers: - name: "metricbeat" diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index eb0f4e9bc..225160b47 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -59,6 +59,10 @@ spec: {{- if .Values.imagePullSecrets }} imagePullSecrets: {{ toYaml .Values.imagePullSecrets | indent 8 }} + {{- end }} + {{- if .Values.extraInitContainers }} + initContainers: +{{ tpl .Values.extraInitContainers . | indent 6 }} {{- end }} containers: - name: "metricbeat" diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index acd3173dc..63839260c 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -58,6 +58,21 @@ def test_adding_a_extra_container(): assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraContainerDeployment +def test_adding_a_extra_init_container(): + config = ''' +extraInitContainers: | + - name: do-something + image: busybox + command: ['do', 'something'] +''' + r = helm_template(config) + extraInitContainerDaemonset = r['daemonset'][name]['spec']['template']['spec']['initContainers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraInitContainerDaemonset + deployment_name = name + '-metrics' + extraInitContainerDeployment = r['deployment'][deployment_name]['spec']['template']['spec']['initContainers'] + assert {'name': 'do-something', 'image': 'busybox', 'command': ['do', 'something'], } in extraInitContainerDeployment + + def test_adding_envs(): config = ''' extraEnvs: diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index 3b9e52a50..9294657a4 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -69,6 +69,11 @@ extraContainers: "" # image: busybox # command: ['echo', 'hey'] +extraInitContainers: "" +# - name: dummy-init +# image: busybox +# command: ['echo', 'hey'] + # Extra environment variables to append to the DaemonSet pod spec. # This will be appended to the current 'env:' key. You can use any of the kubernetes env # syntax here