Просмотр исходного кода

fix(charts): render PDB spec when minAvailable or maxUnavailable is zero (#6360)

Co-authored-by: Gustavo Fernandes de Carvalho <17139678+gusfcarvalho@users.noreply.github.com>
Co-authored-by: Gergely Bräutigam <gergely.brautigam@sap.com>
Signed-off-by: przemyslaw.rudko <48821393+blindrood@users.noreply.github.com>
blindrood 2 недель назад
Родитель
Сommit
5490b91312

+ 2 - 2
deploy/charts/external-secrets/templates/cert-controller-poddisruptionbudget.yaml

@@ -7,9 +7,9 @@ metadata:
   labels:
     {{- include "external-secrets-cert-controller.labels" . | nindent 4 }}
 spec:
-  {{- if .Values.certController.podDisruptionBudget.maxUnavailable }}
+  {{- if hasKey .Values.certController.podDisruptionBudget "maxUnavailable" }}
   maxUnavailable: {{ .Values.certController.podDisruptionBudget.maxUnavailable }}
-  {{- else if .Values.certController.podDisruptionBudget.minAvailable }}
+  {{- else if hasKey .Values.certController.podDisruptionBudget "minAvailable" }}
   minAvailable: {{ .Values.certController.podDisruptionBudget.minAvailable }}
   {{- end }}
   selector:

+ 2 - 2
deploy/charts/external-secrets/templates/poddisruptionbudget.yaml

@@ -7,9 +7,9 @@ metadata:
   labels:
     {{- include "external-secrets.labels" . | nindent 4 }}
 spec:
-  {{- if .Values.podDisruptionBudget.maxUnavailable }}
+  {{- if hasKey .Values.podDisruptionBudget "maxUnavailable" }}
   maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
-  {{- else if .Values.podDisruptionBudget.minAvailable }}
+  {{- else if hasKey .Values.podDisruptionBudget "minAvailable" }}
   minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
   {{- end }}
   selector:

+ 2 - 2
deploy/charts/external-secrets/templates/webhook-poddisruptionbudget.yaml

@@ -8,9 +8,9 @@ metadata:
     {{- include "external-secrets-webhook.labels" . | nindent 4 }}
     external-secrets.io/component: webhook
 spec:
-  {{- if .Values.webhook.podDisruptionBudget.maxUnavailable }}
+  {{- if hasKey .Values.webhook.podDisruptionBudget "maxUnavailable" }}
   maxUnavailable: {{ .Values.webhook.podDisruptionBudget.maxUnavailable }}
-  {{- else if .Values.webhook.podDisruptionBudget.minAvailable }}
+  {{- else if hasKey .Values.webhook.podDisruptionBudget "minAvailable" }}
   minAvailable: {{ .Values.webhook.podDisruptionBudget.minAvailable }}
   {{- end }}
   selector:

+ 25 - 1
deploy/charts/external-secrets/tests/cert_controller_pod_disruption_budget_test.yaml

@@ -20,4 +20,28 @@ tests:
     asserts:
       - equal:
           path: metadata.name
-          value: RELEASE-NAME-external-secrets-cert-controller-pdb
+          value: RELEASE-NAME-external-secrets-cert-controller-pdb
+  - it: should render minAvailable when set to zero
+    set:
+      certController.create: true
+      certController.podDisruptionBudget.enabled: true
+      webhook.certManager.enabled: false
+      certController.podDisruptionBudget.minAvailable: 0
+    asserts:
+      - equal:
+          path: spec.minAvailable
+          value: 0
+      - notExists:
+          path: spec.maxUnavailable
+  - it: should render maxUnavailable when set to zero
+    set:
+      certController.create: true
+      certController.podDisruptionBudget.enabled: true
+      webhook.certManager.enabled: false
+      certController.podDisruptionBudget.maxUnavailable: 0
+    asserts:
+      - equal:
+          path: spec.maxUnavailable
+          value: 0
+      - notExists:
+          path: spec.minAvailable

+ 21 - 1
deploy/charts/external-secrets/tests/pod_disruption_budget_test.yaml

@@ -16,4 +16,24 @@ tests:
     asserts:
       - equal:
           path: metadata.name
-          value: RELEASE-NAME-external-secrets-pdb
+          value: RELEASE-NAME-external-secrets-pdb
+  - it: should render minAvailable when set to zero
+    set:
+      podDisruptionBudget.enabled: true
+      podDisruptionBudget.minAvailable: 0
+    asserts:
+      - equal:
+          path: spec.minAvailable
+          value: 0
+      - notExists:
+          path: spec.maxUnavailable
+  - it: should render maxUnavailable when set to zero
+    set:
+      podDisruptionBudget.enabled: true
+      podDisruptionBudget.maxUnavailable: 0
+    asserts:
+      - equal:
+          path: spec.maxUnavailable
+          value: 0
+      - notExists:
+          path: spec.minAvailable

+ 23 - 1
deploy/charts/external-secrets/tests/webhook_pod_disruption_budget_test.yaml

@@ -18,4 +18,26 @@ tests:
     asserts:
       - equal:
           path: metadata.name
-          value: RELEASE-NAME-external-secrets-webhook-pdb
+          value: RELEASE-NAME-external-secrets-webhook-pdb
+  - it: should render minAvailable when set to zero
+    set:
+      webhook.create: true
+      webhook.podDisruptionBudget.enabled: true
+      webhook.podDisruptionBudget.minAvailable: 0
+    asserts:
+      - equal:
+          path: spec.minAvailable
+          value: 0
+      - notExists:
+          path: spec.maxUnavailable
+  - it: should render maxUnavailable when set to zero
+    set:
+      webhook.create: true
+      webhook.podDisruptionBudget.enabled: true
+      webhook.podDisruptionBudget.maxUnavailable: 0
+    asserts:
+      - equal:
+          path: spec.maxUnavailable
+          value: 0
+      - notExists:
+          path: spec.minAvailable