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

Commit

Permalink
[metricbeat] split envFrom for daemonset and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlrt committed Apr 15, 2020
1 parent 48448cb commit 12d6ffe
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
22 changes: 12 additions & 10 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.6.2
| Parameter | Description | Default |
| --- | --- | --- |
| `daemonset.affinity` | Configurable [affinity][] for Metricbeat `DaemonSet`. | `{}` |
| `daemonset.envFrom` | Templatable string of `envFrom` to be passed to the [environment from variables][] which will be appended to Metricbeat container for `DaemonSet`. | `[]` |
| `daemonset.extraEnvs` | Extra [environment variables][] which will be appended to Metricbeat container for `DaemonSet`. | `[]` |
| `daemonset.metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml` for Metricbeat `DaemonSet`. | see [values.yaml][] |
| `daemonset.nodeSelector` | Configurable [nodeSelector][] for Metricbeat `DaemonSet`. | `{}` |
| `daemonset.securityContext` | Configurable [securityContext][] for Metricbeat `DaemonSet` pod execution environment. | `runAsUser: 0`<br>`privileged: false` |
| `daemonset.resources` | Allows you to set the [resources][] for Metricbeat `DaemonSet`. | `requests.cpu: 100m`<br>`requests.memory: 100Mi`<br>`limits.cpu: 1000m`<br>`limits.memory: 200Mi` |
| `daemonset.tolerations` | Configurable [tolerations][] for Metricbeat `DaemonSet`. | `[]` |
| `deployment.affinity` | Configurable [affinity][] for Metricbeat `Deployment`. | `{}` |
| `deployment.envFrom` | Templatable string of `envFrom` to be passed to the [environment from variables][] which will be appended to Metricbeat container for `Deployment`. | `[]` |
| `deployment.extraEnvs` | Extra [environment variables][] which will be appended to Metricbeat container for `deployment`. | `[]` |
| `deployment.metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml` for Metricbeat `Deployment`. | see [values.yaml][] |
| `deployment.nodeSelector` | Configurable [nodeSelector][] for Metricbeat `Deployment`. | `{}` |
Expand All @@ -85,7 +87,6 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.6.2
| `extraInitContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` |
| `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][] which will be appended to the `envFrom:` definition for the container | `[]` |
| `hostPathRoot` | Fully-qualified [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.6.2` |
Expand All @@ -106,15 +107,16 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.6.2
| `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` |

### Deprecated
| Parameter | Description | Default |
| --- | --- | --- |
| `affinity` | Configurable [affinity][] for Metricbeat `DaemonSet`. | `{}` |
| `extraEnvs` | Extra [environment variables][] which will be appended to Metricbeat container for both `DaemonSet` and `Deployment`. | `[]` |
| `metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml` for both Metricbeat `DaemonSet` and `Deployment`. | `{}` |
| `nodeSelector` | Configurable [nodeSelector][] for Metricbeat `DaemonSet`. | `{}` |
| `podSecurityContext` | Configurable [securityContext][] for Metricbeat `DaemonSet` and `Deployment` pod execution environment. | `{}` |
| `resources` | Allows you to set the [resources][] for both Metricbeat `DaemonSet` and `Deployment`. | `{}` |
| `tolerations` | Configurable [tolerations][] for both Metricbeat `DaemonSet` and `Deployment`. | `[]` |
| Parameter | Description | Default |
| --- | --- | --- |
| `affinity` | Configurable [affinity][] for Metricbeat `DaemonSet`. | `{}` |
| `extraEnvs` | Extra [environment variables][] which will be appended to Metricbeat container for both `DaemonSet` and `Deployment`. | `[]` |
| `deployment.envFrom` | Templatable string to be passed to the [environment from variables][] which will be appended to Metricbeat container for both `DaemonSet` and `Deployment`. | `[]` |
| `metricbeatConfig` | Allows you to add any config files in `/usr/share/metricbeat` such as `metricbeat.yml` for both Metricbeat `DaemonSet` and `Deployment`. | `{}` |
| `nodeSelector` | Configurable [nodeSelector][] for Metricbeat `DaemonSet`. | `{}` |
| `podSecurityContext` | Configurable [securityContext][] for Metricbeat `DaemonSet` and `Deployment` pod execution environment. | `{}` |
| `resources` | Allows you to set the [resources][] for both Metricbeat `DaemonSet` and `Deployment`. | `{}` |
| `tolerations` | Configurable [tolerations][] for both Metricbeat `DaemonSet` and `Deployment`. | `[]` |

## Examples

Expand Down
5 changes: 2 additions & 3 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ spec:
{{- if .Values.extraEnvs | default .Values.daemonset.extraEnvs }}
{{ toYaml ( .Values.extraEnvs | default .Values.daemonset.extraEnvs ) | indent 8 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
{{- if .Values.envFrom | default .Values.daemonset.envFrom }}
envFrom: {{ toYaml ( .Values.envFrom | default .Values.daemonset.envFrom ) | nindent 10 }}
{{- end }}
securityContext: {{ toYaml ( .Values.podSecurityContext | default .Values.daemonset.securityContext ) | nindent 10 }}
volumeMounts:
Expand Down
5 changes: 2 additions & 3 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ spec:
{{- if .Values.extraEnvs | default .Values.deployment.extraEnvs }}
{{ toYaml ( .Values.extraEnvs | default .Values.deployment.extraEnvs ) | indent 8 }}
{{- end }}
{{- if .Values.envFrom }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
{{- if .Values.envFrom | default .Values.deployment.envFrom }}
envFrom: {{ toYaml ( .Values.envFrom | default .Values.deployment.envFrom ) | nindent 10 }}
{{- end }}
securityContext: {{ toYaml ( .Values.podSecurityContext | default .Values.deployment.securityContext ) | nindent 10 }}
volumeMounts:
Expand Down
44 changes: 40 additions & 4 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,51 @@ def test_adding_pod_labels():

def test_adding_env_from():
config = """
daemonset:
envFrom:
- configMapRef:
name: configmap-name
"""
r = helm_template(config)
assert r["daemonset"][name]["spec"]["template"]["spec"]["containers"][0]["envFrom"][
0
]["configMapRef"] == {"name": "configmap-name"}
assert (
"envFrom"
not in r["deployment"][name + "-metrics"]["spec"]["template"]["spec"][
"containers"
][0]
)

config = """
deployment:
envFrom:
- configMapRef:
name: configmap-name
"""
r = helm_template(config)
assert r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]["containers"][
0
]["envFrom"][0]["configMapRef"] == {"name": "configmap-name"}
assert (
"envFrom"
not in r["daemonset"][name]["spec"]["template"]["spec"]["containers"][0]
)


def test_adding_deprecated_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"}
assert r["daemonset"][name]["spec"]["template"]["spec"]["containers"][0]["envFrom"][
0
]["configMapRef"] == {"name": "configmap-name"}
assert r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]["containers"][
0
]["envFrom"][0]["configMapRef"] == {"name": "configmap-name"}


def test_overriding_resources():
Expand Down
11 changes: 7 additions & 4 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
daemonset:
affinity: {}
# Extra environment variables for Metricbeat container.
envFrom: []
# - configMapRef:
# name: config-secret
extraEnvs: []
# - name: MY_ENVIRONMENT_VAR
# value: the_value_goes_here
Expand Down Expand Up @@ -76,6 +79,9 @@ daemonset:
deployment:
affinity: {}
# Extra environment variables for Metricbeat container.
envFrom: []
# - configMapRef:
# name: config-secret
extraEnvs: []
# - name: MY_ENVIRONMENT_VAR
# value: the_value_goes_here
Expand Down Expand Up @@ -131,10 +137,6 @@ 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 Expand Up @@ -227,6 +229,7 @@ fullnameOverride: ""

# DEPRECATED
affinity: {}
envFrom: []
extraEnvs: []
# Allows you to add any config files in /usr/share/metricbeat
# such as metricbeat.yml for both daemonset and deployment
Expand Down

0 comments on commit 12d6ffe

Please sign in to comment.