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

Add support for envfrom #369

Merged
merged 10 commits into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions filebeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ helm install --name filebeat elastic/filebeat --set imageTag=7.5.1
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `filebeatConfig` | Allows you to add any config files in `/usr/share/filebeat` such as `filebeat.yml`. See [values.yaml](./values.yaml) for an example of the formatting with the default configuration. | see [values.yaml](./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 | `[]` |
| `extraVolumeMounts` | List of additional volumeMounts to be mounted on the Daemonset | `""` |
| `extraVolumes` | List of additional volumes to be mounted on 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 | `[]`
| `hostPathRoot` | Fully-qualified [hostPath](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that will be used to persist Filebeat registry data | `/var/lib` |
| `hostNetworking` | Use host networking in the daemonset so that hostname is reported correctly | `false` |
| `image` | The Filebeat docker image | `docker.elastic.co/beats/filebeat` |
Expand Down
4 changes: 4 additions & 0 deletions filebeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ spec:
{{- if .Values.extraEnvs }}
{{ toYaml .Values.extraEnvs | indent 8 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 10 }}
Expand Down
10 changes: 10 additions & 0 deletions filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ def test_priority_class_name():
priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName']
assert priority_class_name == "highest"

def test_adding_env_from():
config = '''
envFrom:
- configMapRef:
name: configmap-name
'''
r = helm_template(config)
configMapRef = r['daemonset'][name]['spec']['template']['spec']['containers'][0]['envFrom'][0]['configMapRef']
assert configMapRef == {'name': 'configmap-name'}

def test_setting_fullnameOverride():
config = '''
fullnameOverride: 'filebeat-custom'
Expand Down
4 changes: 4 additions & 0 deletions filebeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ extraVolumes: []
# - name: extras
# emptyDir: {}

envFrom: []
# - configMapRef:
# name: configmap-name

# Root directory where Filebeat will write data to in order to persist registry data across pod restarts (file position and other metadata).
hostPathRoot: /var/lib
hostNetworking: false
Expand Down
1 change: 1 addition & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.5.1
| `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 | `[]`
| `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.1` |
Expand Down
3 changes: 3 additions & 0 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ spec:
{{- if .Values.extraEnvs }}
{{ toYaml .Values.extraEnvs | indent 8 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
jmymy marked this conversation as resolved.
Show resolved Hide resolved
{{- if .Values.podSecurityContext }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 10 }}
Expand Down
3 changes: 3 additions & 0 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ spec:
{{- if .Values.extraEnvs }}
{{ toYaml .Values.extraEnvs | indent 8 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
jmymy marked this conversation as resolved.
Show resolved Hide resolved
{{- if .Values.podSecurityContext }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 10 }}
Expand Down
10 changes: 10 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ def test_adding_pod_labels():
assert r['daemonset'][name]['metadata']['labels']['app.kubernetes.io/name'] == 'metricbeat'
assert r['daemonset'][name]['spec']['template']['metadata']['labels']['app.kubernetes.io/name'] == 'metricbeat'

def test_adding_env_from():
config = '''
envFrom:
- configMapRef:
name: configmap-name
'''
r = helm_template(config)
configMapRef = r['daemonset'][name]['spec']['template']['spec']['containers'][0]['envFrom'][0]['configMapRef']
assert configMapRef == {'name': 'configmap-name'}

def test_setting_fullnameOverride():
config = '''
fullnameOverride: 'metricbeat-custom'
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ extraVolumes: []
# - name: extras
# emptyDir: {}

envFrom: []
# - configMapRef:
# name: config-secret

# Root directory where metricbeat will write data to in order to persist registry data across pod restarts (file position and other metadata).
hostPathRoot: /var/lib

Expand Down