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

Commit

Permalink
Metricbeat daemonset deployment optional (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
erihanse authored and jmlrt committed Jul 9, 2020
1 parent 3cd31b8 commit e3c8fc6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
8 changes: 5 additions & 3 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ 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.annotations` | Configurable [annotations][] for Metricbeat daemonset | `{}` |
| `daemonset.affinity` | Configurable [affinity][] for Metricbeat daemonset | `{}` |
| `daemonset.enabled` | If true, enable daemonset | `true` |
| `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.extraVolumeMounts` | Templatable string of additional `volumeMounts` to be passed to the `tpl` function or DaemonSet | `[]` |
Expand All @@ -100,8 +101,9 @@ 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.annotations` | Configurable [annotations][] for Metricbeat Deployment | `{}` |
| `deployment.affinity` | Configurable [affinity][] for Metricbeat Deployment | `{}` |
| `deployment.enabled` | If true, enable deployment | `true` |
| `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.extraVolumeMounts` | Templatable string of additional `volumeMounts` to be passed to the `tpl` function or DaemonSet | `[]` |
Expand Down Expand Up @@ -129,7 +131,7 @@ as a reference. They are also used in the automated testing of this chart.
| `readinessProbe` | Parameters to pass to readiness [probe][] checks for values such as timeouts and thresholds | see [values.yaml][] |
| `replicas` | The replica count for the Metricbeat deployment talking to kube-state-metrics | `1` |
| `serviceAccount` | Custom [serviceAccount][] that Metricbeat will use during execution. By default will use the service account created by this chart | `""` |
| `serviceAccountAnnotations` | Annotations to be added to the ServiceAccount that is created by this chart. | `{}`
| `serviceAccountAnnotations` | Annotations to be added to the ServiceAccount that is created by this chart. | `{}` |
| `terminationGracePeriod` | Termination period (in seconds) to wait before killing Metricbeat pod process on pod shutdown | `30` |
| `updateStrategy` | The [updateStrategy][] for the DaemonSet By default Kubernetes will kill and recreate pods on updates. Setting this to `OnDelete` will require that pods be deleted manually | `RollingUpdate` |

Expand Down
2 changes: 2 additions & 0 deletions metricbeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.daemonset.enabled }}
---
apiVersion: apps/v1
kind: DaemonSet
Expand Down Expand Up @@ -165,3 +166,4 @@ spec:
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Deploy singleton instance in the whole cluster for some unique data sources, like kube-state-metrics
{{- if .Values.deployment.enabled }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -129,3 +131,4 @@ spec:
{{- if .Values.extraContainers }}
{{ tpl .Values.extraContainers . | indent 6 }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_defaults():
r = helm_template(config)

assert name in r["daemonset"]
assert name + "-metrics" in r["deployment"]

c = r["daemonset"][name]["spec"]["template"]["spec"]["containers"][0]
assert c["name"] == project
Expand Down Expand Up @@ -1161,3 +1162,23 @@ def test_adding_annotations():
== "waldo"
)
assert "annotations" not in r["daemonset"][name]["metadata"]


def test_disable_daemonset():
config = """
daemonset:
enabled: false
"""
r = helm_template(config)

assert name not in r.get("daemonset", {})


def test_disable_deployment():
config = """
deployment:
enabled: false
"""
r = helm_template(config)

assert name + "-metrics" not in r.get("deployment", {})
4 changes: 4 additions & 0 deletions metricbeat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ daemonset:
# Annotations to apply to the daemonset
annotations: {}
affinity: {}
# Include the daemonset
enabled: true
# Extra environment variables for Metricbeat container.
envFrom: []
# - configMapRef:
Expand Down Expand Up @@ -96,6 +98,8 @@ deployment:
# Annotations to apply to the deployment
annotations: {}
affinity: {}
# Include the deployment
enabled: true
# Extra environment variables for Metricbeat container.
envFrom: []
# - configMapRef:
Expand Down

0 comments on commit e3c8fc6

Please sign in to comment.