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
2 changes: 2 additions & 0 deletions apm-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ 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 | `[]` |
Expand Down
7 changes: 7 additions & 0 deletions apm-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -115,3 +119,6 @@ spec:
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumeMounts | indent 10 }}
{{- end }}
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
24 changes: 24 additions & 0 deletions apm-server/tests/apmserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ 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_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:
Expand Down
12 changes: 11 additions & 1 deletion apm-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ apmConfig:

replicas: 1

extraContainers: ""
# - name: dummy-init
# 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 Expand Up @@ -130,7 +140,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
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand All @@ -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`<br>`requests.memory: 2Gi`<br>`limits.cpu: 1000m`<br>`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`<br>`requests.memory: 2Gi`<br>`limits.cpu: 1000m`<br>`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` |
Expand Down
3 changes: 3 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,6 @@ spec:
lifecycle:
{{ toYaml .Values.lifecycle | indent 10 }}
{{- end }}
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
12 changes: 12 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
5 changes: 5 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions filebeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `[]` |
Expand Down
3 changes: 3 additions & 0 deletions filebeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ spec:
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
13 changes: 13 additions & 0 deletions filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions filebeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ extraVolumes: []
# - name: extras
# emptyDir: {}

extraContainers: ""
# - name: dummy-init
# image: busybox
# command: ['echo', 'hey']

extraInitContainers: []
# - name: dummy-init
# image: busybox
Expand Down
Loading