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

feat(metricbeat): annotation support for daemonset and deployment #713

Merged
merged 9 commits into from
Jul 8, 2020
2 changes: 2 additions & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ as a reference. They are also used in the automated testing of this chart.
| Parameter | Description | Default |
|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|
| `clusterRoleRules` | Configurable [cluster role rules][] that Metricbeat uses to access Kubernetes resources | see [values.yaml][] |
| `daemonset.annotations` | Configurable [annotations][] for Metricbeat daemonset | `{}` |
| `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 | `[]` |
Expand All @@ -84,6 +85,7 @@ as a reference. They are also used in the automated testing of this chart.
| `daemonset.secretMounts` | Allows you easily mount a secret as a file inside the DaemonSet. Useful for mounting certificates and other secrets. See [values.yaml][] for an example | `[]` |
| `daemonset.securityContext` | Configurable [securityContext][] for Metricbeat DaemonSet pod execution environment | see [values.yaml][] |
| `daemonset.tolerations` | Configurable [tolerations][] for Metricbeat DaemonSet | `[]` |
| `deployment.annotations` | Configurable [annotations][] for Metricbeat Deployment | `{}` |
| `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 | `[]` |
Expand Down
6 changes: 6 additions & 0 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ metadata:
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.daemonset.annotations}}
annotations:
{{- range $key, $value := .Values.daemonset.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
selector:
matchLabels:
Expand Down
6 changes: 6 additions & 0 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ metadata:
chart: '{{ .Chart.Name }}-{{ .Chart.Version }}'
heritage: '{{ .Release.Service }}'
release: '{{ .Release.Name }}'
{{- if .Values.deployment.annotations}}
annotations:
{{- range $key, $value := .Values.deployment.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
selector:
Expand Down
24 changes: 24 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,3 +1123,27 @@ def test_setting_fullnameOverride():
"type": "DirectoryOrCreate",
},
} in volumes


def test_adding_annotations():
config = """
daemonset:
annotations:
foo: "bar"
"""
r = helm_template(config)
assert "foo" in r["daemonset"][name]["metadata"]["annotations"]
assert r["daemonset"][name]["metadata"]["annotations"]["foo"] == "bar"
assert "annotations" not in r["deployment"][name + "-metrics"]["metadata"]
config = """
deployment:
annotations:
grault: "waldo"
"""
r = helm_template(config)
assert "grault" in r["deployment"][name + "-metrics"]["metadata"]["annotations"]
assert (
r["deployment"][name + "-metrics"]["metadata"]["annotations"]["grault"]
== "waldo"
)
assert "annotations" not in r["daemonset"][name]["metadata"]
4 changes: 4 additions & 0 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---

daemonset:
# Annotations to apply to the daemonset
annotations: {}
affinity: {}
# Extra environment variables for Metricbeat container.
envFrom: []
Expand Down Expand Up @@ -91,6 +93,8 @@ daemonset:
tolerations: []

deployment:
# Annotations to apply to the deployment
annotations: {}
affinity: {}
# Extra environment variables for Metricbeat container.
envFrom: []
Expand Down