Skip to content

Commit

Permalink
feat(metricbeat): add support for annotations in daemonset and deploy…
Browse files Browse the repository at this point in the history
…ment

PR for elastic#684
  • Loading branch information
kernkonzentrat committed Jul 6, 2020
1 parent e805185 commit fbf9d94
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 23 deletions.
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
22 changes: 22 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,3 +1123,25 @@ 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"]

49 changes: 26 additions & 23 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

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

deployment:
# Annotations to apply to the deployment
annotations: {}
affinity: {}
# Extra environment variables for Metricbeat container.
envFrom: []
Expand Down Expand Up @@ -196,30 +199,30 @@ labels: {}
managedServiceAccount: true

clusterRoleRules:
- apiGroups: [""]
resources:
- nodes
- namespaces
- events
- pods
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources:
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources:
- statefulsets
- deployments
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- nodes/stats
verbs: ["get"]
- apiGroups: [""]
resources:
- nodes
- namespaces
- events
- pods
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources:
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources:
- statefulsets
- deployments
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- nodes/stats
verbs: ["get"]

podAnnotations: {}
# iam.amazonaws.com/role: es-cluster
# iam.amazonaws.com/role: es-cluster

# Custom service account override that the pod will use
serviceAccount: ""
Expand Down

0 comments on commit fbf9d94

Please sign in to comment.