From 00b6fc4e84e2a7114cf188a813ff846e4745d5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Mon, 14 Sep 2020 09:26:41 +0200 Subject: [PATCH 1/8] variable MaxUnavailbale updateStrategy --- filebeat/templates/daemonset.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index 7ac83b0c8..4787c8f99 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -29,7 +29,12 @@ spec: matchLabels: app: "{{ template "filebeat.fullname" . }}" release: {{ .Release.Name | quote }} + {{- if .Values.updateStrategy }} updateStrategy: + {{- if eq .Values.updateStrategy "RollingUpdate" }} + rollingUpdate: + maxUnavailable: {{ .Values.maxUnavailable | default 1 }} + {{- end }} type: {{ .Values.updateStrategy }} template: metadata: From 1872869e05ffcda5e82436cb29df8f7fbb2b08b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Mon, 14 Sep 2020 10:40:46 +0200 Subject: [PATCH 2/8] missing end of if statement.. --- filebeat/templates/daemonset.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index 4787c8f99..b6be129b6 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -36,6 +36,7 @@ spec: maxUnavailable: {{ .Values.maxUnavailable | default 1 }} {{- end }} type: {{ .Values.updateStrategy }} + {{- end }} template: metadata: annotations: From 09a021c4414282c7234ac362cee6375350aae8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Mon, 14 Sep 2020 10:56:01 +0200 Subject: [PATCH 3/8] default MaxUnavailable should be set in values.yaml --- filebeat/templates/daemonset.yaml | 4 +--- filebeat/values.yaml | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index b6be129b6..b300194f7 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -29,14 +29,12 @@ spec: matchLabels: app: "{{ template "filebeat.fullname" . }}" release: {{ .Release.Name | quote }} - {{- if .Values.updateStrategy }} updateStrategy: {{- if eq .Values.updateStrategy "RollingUpdate" }} rollingUpdate: - maxUnavailable: {{ .Values.maxUnavailable | default 1 }} + maxUnavailable: {{ .Values.maxUnavailable }} {{- end }} type: {{ .Values.updateStrategy }} - {{- end }} template: metadata: annotations: diff --git a/filebeat/values.yaml b/filebeat/values.yaml index 747096ea1..7aa2bc1b1 100755 --- a/filebeat/values.yaml +++ b/filebeat/values.yaml @@ -207,6 +207,8 @@ terminationGracePeriod: 30 priorityClassName: "" updateStrategy: RollingUpdate +# Only used when updateStrategy is set to "RollingUpdate" +MaxUnavalaible: 1 # Override various naming aspects of this chart # Only edit these if you know what you're doing From 5d7070eabd89524b0cb91c7efc35eb24ae202eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Mon, 19 Oct 2020 17:55:40 +0200 Subject: [PATCH 4/8] fix typo --- filebeat/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebeat/values.yaml b/filebeat/values.yaml index 7aa2bc1b1..b6cb6600e 100755 --- a/filebeat/values.yaml +++ b/filebeat/values.yaml @@ -208,7 +208,7 @@ priorityClassName: "" updateStrategy: RollingUpdate # Only used when updateStrategy is set to "RollingUpdate" -MaxUnavalaible: 1 +MaxUnavailable: 1 # Override various naming aspects of this chart # Only edit these if you know what you're doing From a4b071ad87952627974638e813064fbb016ae196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Thu, 28 Jan 2021 10:41:40 +0100 Subject: [PATCH 5/8] [filebeat] move maxUnavailable to daemonset scope --- filebeat/templates/daemonset.yaml | 2 +- filebeat/values.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/filebeat/templates/daemonset.yaml b/filebeat/templates/daemonset.yaml index b300194f7..54bfa70b0 100644 --- a/filebeat/templates/daemonset.yaml +++ b/filebeat/templates/daemonset.yaml @@ -32,7 +32,7 @@ spec: updateStrategy: {{- if eq .Values.updateStrategy "RollingUpdate" }} rollingUpdate: - maxUnavailable: {{ .Values.maxUnavailable }} + maxUnavailable: {{ .Values.daemonset.maxUnavailable }} {{- end }} type: {{ .Values.updateStrategy }} template: diff --git a/filebeat/values.yaml b/filebeat/values.yaml index b6cb6600e..8e9daf8da 100755 --- a/filebeat/values.yaml +++ b/filebeat/values.yaml @@ -40,6 +40,8 @@ daemonset: output.elasticsearch: host: '${NODE_NAME}' hosts: '${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}' + # Only used when updateStrategy is set to "RollingUpdate" + maxUnavailable: 1 nodeSelector: {} # A list of secrets and their paths to mount inside the pod # This is useful for mounting certificates for security other sensitive values @@ -207,8 +209,6 @@ terminationGracePeriod: 30 priorityClassName: "" updateStrategy: RollingUpdate -# Only used when updateStrategy is set to "RollingUpdate" -MaxUnavailable: 1 # Override various naming aspects of this chart # Only edit these if you know what you're doing From 20f78add472249f59044af3bd85a74604be2625d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Thu, 28 Jan 2021 10:42:13 +0100 Subject: [PATCH 6/8] [filebeat] add doc for maxUnavailable --- filebeat/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/filebeat/README.md b/filebeat/README.md index f6368b220..9e794c7bb 100644 --- a/filebeat/README.md +++ b/filebeat/README.md @@ -106,6 +106,7 @@ as a reference. They are also used in the automated testing of this chart. | `daemonset.hostAliases` | Configurable [hostAliases][] for filebeat DaemonSet | `[]` | | `daemonset.hostNetworking` | Enable filebeat DaemonSet to use `hostNetwork` | `false` | | `daemonset.filebeatConfig` | Allows you to add any config files in `/usr/share/filebeat` such as `filebeat.yml` for filebeat DaemonSet | see [values.yaml][] | +| `daemonset.maxUnavailable` | The [maxUnavailable][] value for the pod disruption budget. By default this will prevent Kubernetes from having more than 1 unhealthy pod in the node group | `1` | | `daemonset.nodeSelector` | Configurable [nodeSelector][] for filebeat DaemonSet | `{}` | | `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.podSecurityContext` | Configurable [podSecurityContext][] for filebeat DaemonSet pod execution environment | see [values.yaml][] | @@ -258,6 +259,7 @@ about our development and testing process. [kafka output]: https://www.elastic.co/guide/en/beats/filebeat/current/kafka-output.html [kubernetes secrets]: https://kubernetes.io/docs/concepts/configuration/secret/ [labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +[maxUnavailable]: https://kubernetes.io/docs/tasks/run-application/configure-pdb/#specifying-a-poddisruptionbudget [nodeSelector]: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector [podSecurityContext]: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ [priorityClass]: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass From c3cd5a7437a42a029ee91c5d951f1a399a417384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Thu, 28 Jan 2021 10:42:44 +0100 Subject: [PATCH 7/8] [filebeat] add test fior maxUnavailable --- filebeat/tests/filebeat_test.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/filebeat/tests/filebeat_test.py b/filebeat/tests/filebeat_test.py index 9460e8ec6..db69ee223 100644 --- a/filebeat/tests/filebeat_test.py +++ b/filebeat/tests/filebeat_test.py @@ -51,6 +51,8 @@ def test_defaults(): assert r["daemonset"][name]["spec"]["updateStrategy"]["type"] == "RollingUpdate" + assert r["daemonset"][name]["spec"]["updateStrategy"]["rollingUpdate"]["maxUnavailable"] == 1 + assert ( r["daemonset"][name]["spec"]["template"]["spec"]["serviceAccountName"] == name ) @@ -404,7 +406,16 @@ def test_adding_deprecated_tolerations(): def test_override_the_default_update_strategy(): config = """ -updateStrategy: OnDelete + daemonset: + maxUnavailable: 2 +""" + + r = helm_template(config) + assert r["daemonset"][name]["spec"]["updateStrategy"]["type"] == "RollingUpdate" + assert r["daemonset"][name]["spec"]["updateStrategy"]["rollingUpdate"]["maxUnavailable"] == 2 + + config = """ + updateStrategy: OnDelete """ r = helm_template(config) From fe0cae141b54da342cc75b647741bb617bfb219d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chevalier?= Date: Thu, 28 Jan 2021 12:11:48 +0100 Subject: [PATCH 8/8] [filebeat] black format tests --- filebeat/tests/filebeat_test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/filebeat/tests/filebeat_test.py b/filebeat/tests/filebeat_test.py index db69ee223..0a1c100dc 100644 --- a/filebeat/tests/filebeat_test.py +++ b/filebeat/tests/filebeat_test.py @@ -51,7 +51,12 @@ def test_defaults(): assert r["daemonset"][name]["spec"]["updateStrategy"]["type"] == "RollingUpdate" - assert r["daemonset"][name]["spec"]["updateStrategy"]["rollingUpdate"]["maxUnavailable"] == 1 + assert ( + r["daemonset"][name]["spec"]["updateStrategy"]["rollingUpdate"][ + "maxUnavailable" + ] + == 1 + ) assert ( r["daemonset"][name]["spec"]["template"]["spec"]["serviceAccountName"] == name @@ -412,7 +417,12 @@ def test_override_the_default_update_strategy(): r = helm_template(config) assert r["daemonset"][name]["spec"]["updateStrategy"]["type"] == "RollingUpdate" - assert r["daemonset"][name]["spec"]["updateStrategy"]["rollingUpdate"]["maxUnavailable"] == 2 + assert ( + r["daemonset"][name]["spec"]["updateStrategy"]["rollingUpdate"][ + "maxUnavailable" + ] + == 2 + ) config = """ updateStrategy: OnDelete