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

Commit

Permalink
[metricbeat] use deprecated kube-state-metrics config when existing (#…
Browse files Browse the repository at this point in the history
…624)

This commit fix a bug introduced in #572 where Metricbeat deployment doesn't start after an upgrade from a previous version when using a custom metricbeatConfig.
  • Loading branch information
jmlrt committed May 28, 2020
1 parent 1349a2d commit 9c0c9a5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 88 deletions.
77 changes: 0 additions & 77 deletions BREAKING_CHANGES.md

This file was deleted.

4 changes: 4 additions & 0 deletions metricbeat/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ spec:
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
args:
{{- if index .Values "metricbeatConfig" "kube-state-metrics-metricbeat.yml" }}
- "-c"
- "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml"
{{- end }}
- "-e"
- "-E"
- "http.enabled=true"
Expand Down
51 changes: 40 additions & 11 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,48 +537,77 @@ def test_adding_in_deprecated_metricbeat_config():
nestedkey: value
dot.notation: test
other-config.yml: |
kube-state-metrics-metricbeat.yml: |
hello = world
"""
r = helm_template(config)
c = r["configmap"][name + "-config"]["data"]

assert "metricbeat.yml" in c
assert "other-config.yml" in c
assert "kube-state-metrics-metricbeat.yml" in c

assert "nestedkey: value" in c["metricbeat.yml"]
assert "dot.notation: test" in c["metricbeat.yml"]

assert "hello = world" in c["other-config.yml"]
assert "hello = world" in c["kube-state-metrics-metricbeat.yml"]

d = r["daemonset"][name]["spec"]["template"]["spec"]
daemonset = r["daemonset"][name]["spec"]["template"]["spec"]

assert {
"configMap": {"name": name + "-config", "defaultMode": 0o600},
"name": project + "-config",
} in d["volumes"]
} in daemonset["volumes"]
assert {
"mountPath": "/usr/share/metricbeat/metricbeat.yml",
"name": project + "-config",
"subPath": "metricbeat.yml",
"readOnly": True,
} in d["containers"][0]["volumeMounts"]
} in daemonset["containers"][0]["volumeMounts"]
assert {
"mountPath": "/usr/share/metricbeat/other-config.yml",
"mountPath": "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml",
"name": project + "-config",
"subPath": "other-config.yml",
"subPath": "kube-state-metrics-metricbeat.yml",
"readOnly": True,
} in d["containers"][0]["volumeMounts"]
} in daemonset["containers"][0]["volumeMounts"]

assert (
"configChecksum"
in r["daemonset"][name]["spec"]["template"]["metadata"]["annotations"]
)

deployment = r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]

assert {
"configMap": {"name": name + "-config", "defaultMode": 0o600},
"name": project + "-config",
} in deployment["volumes"]
assert {
"mountPath": "/usr/share/metricbeat/metricbeat.yml",
"name": project + "-config",
"subPath": "metricbeat.yml",
"readOnly": True,
} in deployment["containers"][0]["volumeMounts"]
assert {
"mountPath": "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml",
"name": project + "-config",
"subPath": "kube-state-metrics-metricbeat.yml",
"readOnly": True,
} in deployment["containers"][0]["volumeMounts"]
assert ("/usr/share/metricbeat/kube-state-metrics-metricbeat.yml") in deployment[
"containers"
][0]["args"]

assert (
"configChecksum"
in r["deployment"][name + "-metrics"]["spec"]["template"]["metadata"][
"annotations"
]
)


def test_adding_a_secret_mount():
config = """
daemonset:
daemonset:
secretMounts:
- name: elastic-certificates
secretName: elastic-certificates-name
Expand Down Expand Up @@ -614,7 +643,7 @@ def test_adding_a_secret_mount():
} not in r["deployment"][name + "-metrics"]["spec"]["template"]["spec"]["volumes"]

config = """
deployment:
deployment:
secretMounts:
- name: elastic-certificates
secretName: elastic-certificates-name
Expand Down

0 comments on commit 9c0c9a5

Please sign in to comment.