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

Add extraContainers and extraInitContainers for all charts #473

Merged
merged 11 commits into from
Feb 10, 2020
Prev Previous commit
[metricbeat] add extra init containers
  • Loading branch information
jmlrt committed Feb 6, 2020
commit 3d482df987b98756d1876f9a701e9305b9f43378
1 change: 1 addition & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `""` |
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down