From 31a94a843193ab003fa40ea75fc0426cdbb0922f Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 9 Sep 2024 13:52:36 +0900 Subject: [PATCH] chore: Changed the process to expand yaml so that maxUnavailable, etc. can be used. Signed-off-by: kahirokunn --- cmd/build/helmify/kustomize-for-helm.yaml | 2 +- cmd/build/helmify/replacements.go | 12 +++++++++++- config/pdb/pdb.yaml | 1 - deploy/gatekeeper.yaml | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/build/helmify/kustomize-for-helm.yaml b/cmd/build/helmify/kustomize-for-helm.yaml index 8e87903194c..a4fb6da34c3 100644 --- a/cmd/build/helmify/kustomize-for-helm.yaml +++ b/cmd/build/helmify/kustomize-for-helm.yaml @@ -310,7 +310,7 @@ metadata: name: gatekeeper-controller-manager namespace: gatekeeper-system spec: - minAvailable: HELMSUBST_PDB_CONTROLLER_MANAGER_MINAVAILABLE + HELMSUBST_PDB_CONTROLLER_MANAGER: "" selector: matchLabels: control-plane: controller-manager diff --git a/cmd/build/helmify/replacements.go b/cmd/build/helmify/replacements.go index d95ed289c19..61fc136aaf6 100644 --- a/cmd/build/helmify/replacements.go +++ b/cmd/build/helmify/replacements.go @@ -248,7 +248,17 @@ var replacements = map[string]string{ "HELMSUBST_MUTATING_WEBHOOK_MATCH_CONDITIONS": `{{ toYaml .Values.mutatingWebhookMatchConditions | nindent 4 }}`, - "HELMSUBST_PDB_CONTROLLER_MANAGER_MINAVAILABLE": `{{ .Values.pdb.controllerManager.minAvailable }}`, + "HELMSUBST_PDB_CONTROLLER_MANAGER": `{{- if and .Values.maxAvailable .Values.maxUnavailable }} + {{ fail "Only one of 'maxAvailable' or 'maxUnavailable' can be set, but not both" }} + {{- else if not (or .Values.maxAvailable .Values.maxUnavailable) }} + {{ fail "One of 'maxAvailable' or 'maxUnavailable' must be set" }} + {{- else }} + {{ if .Values.maxAvailable }} + maxAvailable: {{ .Values.maxAvailable }} + {{ else if .Values.maxUnavailable }} + maxUnavailable: {{ .Values.maxUnavailable }} + {{ end }} + {{- end }}`, `HELMSUBST_AUDIT_CONTROLLER_MANAGER_DEPLOYMENT_IMAGE_RELEASE: ""`: `{{- if .Values.image.release }} image: {{ .Values.image.repository }}:{{ .Values.image.release }} diff --git a/config/pdb/pdb.yaml b/config/pdb/pdb.yaml index ff78d145bb3..e80f569fbd3 100644 --- a/config/pdb/pdb.yaml +++ b/config/pdb/pdb.yaml @@ -3,7 +3,6 @@ kind: PodDisruptionBudget metadata: name: controller-manager spec: - minAvailable: 1 selector: matchLabels: control-plane: controller-manager diff --git a/deploy/gatekeeper.yaml b/deploy/gatekeeper.yaml index fe375e4eb43..8cfc24be115 100644 --- a/deploy/gatekeeper.yaml +++ b/deploy/gatekeeper.yaml @@ -5141,7 +5141,6 @@ metadata: name: gatekeeper-controller-manager namespace: gatekeeper-system spec: - minAvailable: 1 selector: matchLabels: control-plane: controller-manager