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

[metricbeat] Make cluster role rules configurable #310

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.3.2
| `imagePullPolicy` | The Kubernetes [imagePullPolicy](https://kubernetes.io/docs/concepts/containers/images/#updating-images) value | `IfNotPresent` |
| `imagePullSecrets` | Configuration for [imagePullSecrets](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-pod-that-uses-your-secret) so that you can use a private registry for your image | `[]` |
| `managedServiceAccount` | Whether the `serviceAccount` should be managed by this helm chart. Set this to `false` in order to manage your own service account and related roles. | `true` |
| `clusterRoleRules` | Configurable [cluster role rules](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole) that Metricbeat uses to access Kubernetes resources. | see [values.yaml](./values.yaml) |
| `podAnnotations` | Configurable [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) applied to all Metricbeat pods | `{}` |
| `podSecurityContext` | Configurable [podSecurityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) for Metricbeat pod execution environment | `runAsUser: 0`<br>`privileged: false` |
| `livenessProbe` | Parameters to pass to [liveness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) checks for values such as timeouts and thresholds. | `failureThreshold: 3`<br>`initialDelaySeconds: 10`<br>`periodSeconds: 10`<br>`successThreshold: 3`<br>`timeoutSeconds: 5` |
Expand Down
12 changes: 1 addition & 11 deletions metricbeat/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,5 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
rules:
- apiGroups:
- ""
resources:
- namespaces
- pods
- events
verbs:
- get
- list
- watch
rules: {{ toYaml .Values.clusterRoleRules | nindent 2 -}}
{{- end -}}
23 changes: 23 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,26 @@ def test_adding_an_affinity_rule():
r = helm_template(config)
assert r['daemonset'][name]['spec']['template']['spec']['affinity']['podAntiAffinity'][
'requiredDuringSchedulingIgnoredDuringExecution'][0]['topologyKey'] == 'kubernetes.io/hostname'

def test_cluster_role_rules():
config = ''
r = helm_template(config)
rules = r['clusterrole']['release-name-metricbeat-cluster-role']['rules'][0]
assert rules['apiGroups'][0] == 'extensions'
assert rules['verbs'][0] == 'get'
assert rules['resources'][0] == 'namespaces'

config = '''
clusterRoleRules:
- apiGroups:
- "someone"
verbs:
- "or"
resources:
- "something"
'''
r = helm_template(config)
rules = r['clusterrole']['release-name-metricbeat-cluster-role']['rules'][0]
assert rules['apiGroups'][0] == 'someone'
assert rules['verbs'][0] == 'or'
assert rules['resources'][0] == 'something'
17 changes: 17 additions & 0 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,23 @@ readinessProbe:
# Whether this chart should self-manage its service account, role, and associated role binding.
managedServiceAccount: true

clusterRoleRules:
- apiGroups:
- "extensions"
- "apps"
- ""
resources:
- namespaces
- pods
- events
- deployments
- nodes
- replicasets
verbs:
- get
- list
- watch

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

Expand Down