diff --git a/metricbeat/README.md b/metricbeat/README.md index 34c268570..ff3ebafe7 100644 --- a/metricbeat/README.md +++ b/metricbeat/README.md @@ -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 | `[]` | @@ -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 | `[]` | @@ -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` | diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 3b0e4fe68..39ffd0a84 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -1,3 +1,4 @@ +{{- if .Values.daemonset.enabled }} --- apiVersion: apps/v1 kind: DaemonSet @@ -165,3 +166,4 @@ spec: {{- if .Values.extraContainers }} {{ tpl .Values.extraContainers . | indent 6 }} {{- end }} +{{- end }} diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index 3e62e7e51..abb02b4cc 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -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 @@ -129,3 +131,4 @@ spec: {{- if .Values.extraContainers }} {{ tpl .Values.extraContainers . | indent 6 }} {{- end }} +{{- end }} diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index a0c97798c..9f78aeb33 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -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 @@ -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", {}) diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index a0ff2af6f..76e4489d7 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -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: @@ -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: