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

Commit

Permalink
[Metricbeat] Dont generate config if not enabled (#767)
Browse files Browse the repository at this point in the history
If for daemonset/deployment is not enabled, dont generate useless config YAML.
  • Loading branch information
ebuildy authored and jmlrt committed Oct 20, 2020
1 parent 5918d20 commit d8f2b4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metricbeat/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
{{- end -}}
{{- end -}}

{{- if .Values.daemonset.metricbeatConfig }}
{{- if and .Values.daemonset.enabled .Values.daemonset.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -34,7 +34,7 @@ data:
{{- end -}}
{{- end -}}

{{- if .Values.deployment.metricbeatConfig }}
{{- if and .Values.deployment.enabled .Values.deployment.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
Expand Down
6 changes: 6 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,8 +1257,11 @@ def test_disable_daemonset():
enabled: false
"""
r = helm_template(config)
cfg = r["configmap"]

assert name not in r.get("daemonset", {})
assert name + "-daemonset-config" not in cfg
assert name + "-deployment-config" in cfg


def test_disable_deployment():
Expand All @@ -1267,8 +1270,11 @@ def test_disable_deployment():
enabled: false
"""
r = helm_template(config)
cfg = r["configmap"]

assert name + "-metrics" not in r.get("deployment", {})
assert name + "-daemonset-config" in cfg
assert name + "-deployment-config" not in cfg


def test_do_not_install_kube_stat_metrics():
Expand Down

0 comments on commit d8f2b4b

Please sign in to comment.