From b5ac94e64ecee68bef6f224e81f542b1f744f33d Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 14 Sep 2023 15:39:39 +0200 Subject: [PATCH 1/4] PDB for wiki --- charts/wiki/templates/pdb.yaml | 18 ++++++++++++++++++ charts/wiki/values.yaml | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 charts/wiki/templates/pdb.yaml diff --git a/charts/wiki/templates/pdb.yaml b/charts/wiki/templates/pdb.yaml new file mode 100644 index 000000000..81398dd4d --- /dev/null +++ b/charts/wiki/templates/pdb.yaml @@ -0,0 +1,18 @@ +{{- if .Values.poddisruptionbudget.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "wiki.fullname" . }} + labels: + {{- include "wiki.labels" . | nindent 4 }} +spec: + {{- with .Values.poddisruptionbudget.minAvailable }} + minAvailable: {{ . }} + {{- end }} + {{- with .Values.poddisruptionbudget.maxUnavailable }} + maxUnavailable: {{ . }} + {{- end }} + selector: + matchLabels: + app: {{ include "wiki.fullname" . }} +{{- end }} diff --git a/charts/wiki/values.yaml b/charts/wiki/values.yaml index 5a1510cea..4d2c52592 100644 --- a/charts/wiki/values.yaml +++ b/charts/wiki/values.yaml @@ -66,3 +66,7 @@ autoscaling: nodeSelector: {} tolerations: [] affinity: {} +poddisruptionbudget: + enabled: false + minAvailable: 1 + maxUnavailable: 1 From 031837eb89c1e3e4358b7dfcdc6852f800251d12 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 14 Sep 2023 15:45:19 +0200 Subject: [PATCH 2/4] do not forget to bump application version --- charts/wiki/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/wiki/Chart.yaml b/charts/wiki/Chart.yaml index 8938d76e1..3e9c05e42 100644 --- a/charts/wiki/Chart.yaml +++ b/charts/wiki/Chart.yaml @@ -3,4 +3,4 @@ appVersion: 0.0.7 description: A Helm chart for wiki static content name: wiki type: application -version: 0.3.99 +version: 0.4.0 From f3481c6f6628135d535bed83301529aa5316e7d4 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 18 Sep 2023 14:24:25 +0200 Subject: [PATCH 3/4] add unit test for PDB --- .../tests/test-poddisruptionbudget.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 charts/wiki/templates/tests/test-poddisruptionbudget.yaml diff --git a/charts/wiki/templates/tests/test-poddisruptionbudget.yaml b/charts/wiki/templates/tests/test-poddisruptionbudget.yaml new file mode 100644 index 000000000..83fe735d0 --- /dev/null +++ b/charts/wiki/templates/tests/test-poddisruptionbudget.yaml @@ -0,0 +1,17 @@ +suite: test pdb.yaml +templates: + - pdb.yaml +tests: + - it: should ensure the pdb has correct spec + set: + poddisruptionbudget.minAvailable: 2 + poddisruptionbudget.maxUnavailable: 1 + asserts: + - isKind: + of: PodDisruptionBudget + - equal: + path: spec.minAvailable + value: 2 + - equal: + path: spec.selector.matchLabels.app + value: "wiki" From 465bacffab57718e6c9cfbf6c8b54152dd5dd49e Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 18 Sep 2023 17:39:09 +0200 Subject: [PATCH 4/4] new unit tests --- charts/wiki/templates/tests/test-connection.yaml | 15 --------------- .../custom_values_test.yaml} | 5 +++-- charts/wiki/tests/defaults_test.yaml | 9 +++++++++ 3 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 charts/wiki/templates/tests/test-connection.yaml rename charts/wiki/{templates/tests/test-poddisruptionbudget.yaml => tests/custom_values_test.yaml} (77%) create mode 100644 charts/wiki/tests/defaults_test.yaml diff --git a/charts/wiki/templates/tests/test-connection.yaml b/charts/wiki/templates/tests/test-connection.yaml deleted file mode 100644 index c0d06cbc6..000000000 --- a/charts/wiki/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "wiki.fullname" . }}-test-connection" - labels: - {{- include "wiki.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "wiki.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/charts/wiki/templates/tests/test-poddisruptionbudget.yaml b/charts/wiki/tests/custom_values_test.yaml similarity index 77% rename from charts/wiki/templates/tests/test-poddisruptionbudget.yaml rename to charts/wiki/tests/custom_values_test.yaml index 83fe735d0..d21bd2417 100644 --- a/charts/wiki/templates/tests/test-poddisruptionbudget.yaml +++ b/charts/wiki/tests/custom_values_test.yaml @@ -1,9 +1,10 @@ -suite: test pdb.yaml +suite: Tests with custom values templates: - pdb.yaml tests: - it: should ensure the pdb has correct spec set: + poddisruptionbudget.enabled: true poddisruptionbudget.minAvailable: 2 poddisruptionbudget.maxUnavailable: 1 asserts: @@ -14,4 +15,4 @@ tests: value: 2 - equal: path: spec.selector.matchLabels.app - value: "wiki" + value: "RELEASE-NAME-wiki" diff --git a/charts/wiki/tests/defaults_test.yaml b/charts/wiki/tests/defaults_test.yaml new file mode 100644 index 000000000..8b8f74624 --- /dev/null +++ b/charts/wiki/tests/defaults_test.yaml @@ -0,0 +1,9 @@ +suite: default tests +templates: + - pdb.yaml +tests: + - it: should not generate any pdb with default values + template: pdb.yaml + asserts: + - hasDocuments: + count: 0