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

Commit

Permalink
Merge pull request #530 from elastic/filebeat-extra-init
Browse files Browse the repository at this point in the history
Accept a string as extraInitContainers value for filebeat
  • Loading branch information
jmlrt committed Mar 19, 2020
2 parents 8f21b1b + dcd5828 commit 6fda6d0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion filebeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ helm install --name filebeat elastic/filebeat --set imageTag=7.6.1
| `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 | `[]` |
| `extraInitContainers` | List of additional init containers to be added at the Daemonset. It also accepts a templatable string of additional containers to be passed to the `tpl` function | `[]` |
| `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 | `[]` |
Expand Down
10 changes: 10 additions & 0 deletions filebeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ spec:
{{- end }}
{{- if .Values.extraInitContainers }}
initContainers:
# All the other beats accept a string here while
# filebeat accepts a valid yaml array. We're keeping
# this as a backwards compatible change, while adding
# also a way to pass a string as other templates to
# make these implementations consistent.
# https://github.com/elastic/helm-charts/issues/490
{{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
{{ tpl .Values.extraInitContainers . | indent 8 }}
{{- else }}
{{ toYaml .Values.extraInitContainers | indent 8 }}
{{- end }}
{{- end }}
containers:
- name: "filebeat"
Expand Down
18 changes: 17 additions & 1 deletion filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_adding_a_extra_container():
} in extraContainer


def test_adding_init_containers():
def test_adding_init_containers_as_yaml():
config = """
extraInitContainers:
- name: dummy-init
Expand All @@ -90,6 +90,22 @@ def test_adding_init_containers():
} in initContainers


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 = """
imagePullSecrets:
Expand Down

0 comments on commit 6fda6d0

Please sign in to comment.