From 13b6865635d2a3314a99fd7d1a1fc785f95a73fd Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Fri, 15 May 2020 20:07:33 +0200 Subject: [PATCH 01/10] [metricbeat] use deprecated kube-state-metrics config when existing --- metricbeat/templates/deployment.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index ca056d42b..06efe0e75 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -73,6 +73,10 @@ spec: image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" args: + {{- if .Values.metricbeatConfig }} + - "-c" + - "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml" + {{- end }} - "-e" - "-E" - "http.enabled=true" @@ -119,4 +123,4 @@ spec: {{- end }} {{- if .Values.extraContainers }} {{ tpl .Values.extraContainers . | indent 6 }} - {{- end }} \ No newline at end of file + {{- end }} From 4292f53e65fe1b3f9efaf75feba4607e695b1c68 Mon Sep 17 00:00:00 2001 From: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> Date: Mon, 18 May 2020 10:55:04 +0200 Subject: [PATCH 02/10] Update metricbeat/templates/deployment.yaml Co-authored-by: Michael Russell --- metricbeat/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index 06efe0e75..fe49cd826 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -73,7 +73,7 @@ spec: image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" args: - {{- if .Values.metricbeatConfig }} + {{- if .Values.metricbeatConfig.kube-state-metrics-metricbeat.yml }} - "-c" - "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml" {{- end }} From 060d07997cb9f60ac5b7471c7d4ef834e5dce9d4 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Mon, 18 May 2020 10:58:57 +0200 Subject: [PATCH 03/10] [metricbeat] fix deployment upgrade by removing chart label from .spec.selector.matchLabels (#622) This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See https://github.com/helm/charts/issues/7680 for more details --- BREAKING_CHANGES.md | 11 +++++++++++ metricbeat/templates/deployment.yaml | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 75a4db036..43e488aab 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -7,7 +7,9 @@ - [GA support](#ga-support) - [New branching model](#new-branching-model) - [Filebeat container inputs](#filebeat-container-inputs) + - [Metricbeat upgrade issue](#metricbeat-upgrade-issue) - [Metricbeat split values for daemonset and deployment](#metricbeat-split-values-for-daemonset-and-deployment) +- [6.8.9 - 2020/05/13](#689---20200513) - [7.6.2 - 2020/03/31](#762---20200331) - [Kibana default resources](#kibana-default-resources) - [7.6.0 - 2020/02/11](#760---20200211) @@ -48,6 +50,14 @@ Docker images Filebeat chart default config is now using [container input][] instead of [docker input][] in [#568][]. +### Metricbeat upgrade issue + +Metricbeat upgrade are failing with +`spec.selector: Invalid value: ... field is immutable` error. This is related to +Metricbeat deployment selector including chart version which is not immutable. +You should use `helm upgrade --force` to upgrade Metricbeat. See [#621][] for +more details. + ### Metricbeat split values for daemonset and deployment Metricbeat is now using dedicated values for daemonset and deployment config. @@ -153,6 +163,7 @@ volumeClaimTemplate: [#540]: https://github.com/elastic/helm-charts/pull/540 [#568]: https://github.com/elastic/helm-charts/pull/568 [#572]: https://github.com/elastic/helm-charts/pull/572 +[#621]: https://github.com/elastic/helm-charts/pull/621 [container input]: https://www.elastic.co/guide/en/beats/filebeat/7.7/filebeat-input-container.html [docker input]: https://www.elastic.co/guide/en/beats/filebeat/7.7/filebeat-input-docker.html [elastic helm repo]: https://helm.elastic.co diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index fe49cd826..52b5266d0 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -13,7 +13,6 @@ spec: selector: matchLabels: app: '{{ template "metricbeat.fullname" . }}-metrics' - chart: '{{ .Chart.Name }}-{{ .Chart.Version }}' heritage: '{{ .Release.Service }}' release: '{{ .Release.Name }}' template: From e4d8a7960dcfa84d8fdb72b8bf811abc90f6d786 Mon Sep 17 00:00:00 2001 From: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> Date: Mon, 18 May 2020 11:49:21 +0200 Subject: [PATCH 04/10] [metricbeat] add breaking changes notices --- BREAKING_CHANGES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 43e488aab..33657f4a2 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -64,6 +64,14 @@ Metricbeat is now using dedicated values for daemonset and deployment config. The old values are still working but are now deprecated. See [#572][] for more details. +Warning: When upgrading Metricbeat while using custom `metricbeatConfig` value +for `kube-state-metrics-metricbeat.yml`, Metricbeat deployment fails with +`missing field accessing 'metricbeat.modules.0.hosts.0' (source:'metricbeat.yml')`. + +In this case `metricbeatConfig.kube-state-metrics-metricbeat.yml` value should +be migrated to `deployment.metricbeatConfig.metricbeat.yml`. See [#623][] for +more details. + ## 6.8.9 - 2020/05/13 See [7.7.0 Breaking changes](#770---20200513) @@ -164,6 +172,7 @@ volumeClaimTemplate: [#568]: https://github.com/elastic/helm-charts/pull/568 [#572]: https://github.com/elastic/helm-charts/pull/572 [#621]: https://github.com/elastic/helm-charts/pull/621 +[#623]: https://github.com/elastic/helm-charts/pull/623 [container input]: https://www.elastic.co/guide/en/beats/filebeat/7.7/filebeat-input-container.html [docker input]: https://www.elastic.co/guide/en/beats/filebeat/7.7/filebeat-input-docker.html [elastic helm repo]: https://helm.elastic.co From 2c68de5d19dd1bb78ea7664c50e082ec4bd3d3f5 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Mon, 18 May 2020 15:48:26 +0200 Subject: [PATCH 05/10] [metricbeat] fix template if condition --- metricbeat/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index 52b5266d0..b7993c175 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -72,7 +72,7 @@ spec: image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" args: - {{- if .Values.metricbeatConfig.kube-state-metrics-metricbeat.yml }} + {{- if ".Values.metricbeatConfig.kube-state-metrics-metricbeat.yml" }} - "-c" - "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml" {{- end }} From 987729ca486401be888ed43d5b03f93d66feddd2 Mon Sep 17 00:00:00 2001 From: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> Date: Mon, 18 May 2020 15:48:50 +0200 Subject: [PATCH 06/10] [metricbeat] update tests --- metricbeat/tests/metricbeat_test.py | 51 ++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/metricbeat/tests/metricbeat_test.py b/metricbeat/tests/metricbeat_test.py index 83265498d..1e0e407d2 100644 --- a/metricbeat/tests/metricbeat_test.py +++ b/metricbeat/tests/metricbeat_test.py @@ -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 @@ -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 From e3e135a27e3517b833e6a7689fd7f1d46c3fe70b Mon Sep 17 00:00:00 2001 From: Maximilian Rink Date: Wed, 27 May 2020 23:03:45 +0200 Subject: [PATCH 07/10] Fix configchecksum not being set (#634) --- metricbeat/templates/daemonset.yaml | 2 +- metricbeat/templates/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 188db442b..3c7a6c545 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -25,7 +25,7 @@ spec: {{ $key }}: {{ $value | quote }} {{- end }} {{/* This forces a restart if the configmap has changed */}} - {{- if .Values.metricbeatConfig }} + {{- if or .Values.metricbeatConfig .Values.daemonset.metricbeatConfig }} configChecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }} {{- end }} name: "{{ template "metricbeat.fullname" . }}" diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index b7993c175..c00e6b7c8 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -22,7 +22,7 @@ spec: {{ $key }}: {{ $value | quote }} {{- end }} {{/* This forces a restart if the configmap has changed */}} - {{- if .Values.metricbeatConfig }} + {{- if or .Values.metricbeatConfig .Values.deployment.metricbeatConfig }} configChecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }} {{- end }} labels: From 8b645c75f39d0eb2fcecf896d9468863d9a40007 Mon Sep 17 00:00:00 2001 From: Stefan Keranov Date: Wed, 27 May 2020 23:05:58 +0100 Subject: [PATCH 08/10] Fix values links in examples/multi/README.md (#639) --- elasticsearch/examples/multi/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch/examples/multi/README.md b/elasticsearch/examples/multi/README.md index 06b2a2f2a..9197c5fbb 100644 --- a/elasticsearch/examples/multi/README.md +++ b/elasticsearch/examples/multi/README.md @@ -22,6 +22,6 @@ releases: You can also run [goss integration tests][] using `make test` -[data values]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/multi/data.yaml +[data values]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/multi/data.yml [goss integration tests]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/multi/test/goss.yaml -[master values]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/multi/master.yaml +[master values]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/multi/master.yml From 4689c0c46709df917a2d50233ab3ff92c1d4d38c Mon Sep 17 00:00:00 2001 From: Max Kochubey Date: Thu, 28 May 2020 05:13:47 +0700 Subject: [PATCH 09/10] [kibana] String/YAML conditions for `.Values.{extraContainers,extraInitContainers}` (#637) --- kibana/templates/deployment.yaml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml index aca2ee153..9d7109265 100644 --- a/kibana/templates/deployment.yaml +++ b/kibana/templates/deployment.yaml @@ -69,8 +69,15 @@ spec: {{ toYaml .Values.imagePullSecrets | indent 8 }} {{- end }} {{- if .Values.extraInitContainers }} + # Currently some extra blocks accept strings + # to continue with backwards compatibility this is being kept + # whilst also allowing for yaml to be specified too. initContainers: + {{- if eq "string" (printf "%T" .Values.extraInitContainers) }} {{ tpl .Values.extraInitContainers . | indent 6 }} + {{- else }} +{{ toYaml .Values.extraInitContainers | indent 6 }} + {{- end }} {{- end }} containers: - name: kibana @@ -143,5 +150,12 @@ spec: subPath: {{ $path }} {{- end -}} {{- if .Values.extraContainers }} + # Currently some extra blocks accept strings + # to continue with backwards compatibility this is being kept + # whilst also allowing for yaml to be specified too. + {{- if eq "string" (printf "%T" .Values.extraContainers) }} {{ tpl .Values.extraContainers . | indent 6 }} - {{- end }} \ No newline at end of file + {{- else }} +{{ toYaml .Values.extraContainers | indent 6 }} + {{- end }} + {{- end }} From 235e4e4b2a56908f67747e2b60986d8862196d23 Mon Sep 17 00:00:00 2001 From: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> Date: Thu, 28 May 2020 12:04:15 +0200 Subject: [PATCH 10/10] [metricbeat] use index to get metricbeatConfig.kube-state-metrics-metricbeat.yml value This is requires because helm doesn't support accessing values with dash in the name (see https://github.com/helm/helm/issues/2192 for more details). --- metricbeat/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metricbeat/templates/deployment.yaml b/metricbeat/templates/deployment.yaml index c00e6b7c8..830438835 100644 --- a/metricbeat/templates/deployment.yaml +++ b/metricbeat/templates/deployment.yaml @@ -72,7 +72,7 @@ spec: image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" args: - {{- if ".Values.metricbeatConfig.kube-state-metrics-metricbeat.yml" }} + {{- if index .Values "metricbeatConfig" "kube-state-metrics-metricbeat.yml" }} - "-c" - "/usr/share/metricbeat/kube-state-metrics-metricbeat.yml" {{- end }}