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

Commit

Permalink
feat(metricbeat): annotation support for daemonset and deployment (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
kernkonzentrat authored and Gavin Williams committed Jul 8, 2020
1 parent feec797 commit a5fec3e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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 @@ -99,6 +100,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 @@ -1137,3 +1137,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

0 comments on commit a5fec3e

Please sign in to comment.