From b6452f20bca7b8e3ed796c29285df774cbcf0776 Mon Sep 17 00:00:00 2001 From: Parichay Didwania Date: Tue, 6 Aug 2024 20:00:01 -0400 Subject: [PATCH 1/2] fix(helm): Allow pdb minAvailable to take precedence over default maxUnavailable --- charts/cluster-autoscaler/Chart.yaml | 2 +- charts/cluster-autoscaler/templates/pdb.yaml | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/charts/cluster-autoscaler/Chart.yaml b/charts/cluster-autoscaler/Chart.yaml index f2548d86f4..2f533563ef 100644 --- a/charts/cluster-autoscaler/Chart.yaml +++ b/charts/cluster-autoscaler/Chart.yaml @@ -11,4 +11,4 @@ name: cluster-autoscaler sources: - https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler type: application -version: 9.46.2 +version: 9.46.3 diff --git a/charts/cluster-autoscaler/templates/pdb.yaml b/charts/cluster-autoscaler/templates/pdb.yaml index 8ad782096b..75e00ebed4 100644 --- a/charts/cluster-autoscaler/templates/pdb.yaml +++ b/charts/cluster-autoscaler/templates/pdb.yaml @@ -10,7 +10,10 @@ spec: selector: matchLabels: {{ include "cluster-autoscaler.instance-name" . | indent 6 }} -{{- if .Values.podDisruptionBudget }} - {{ toYaml .Values.podDisruptionBudget | nindent 2 }} -{{- end }} + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if and .Values.podDisruptionBudget.maxUnavailable (not .Values.podDisruptionBudget.minAvailable) }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} {{- end -}} From b8068894857115068ed51c2827dc7b1c310ad825 Mon Sep 17 00:00:00 2001 From: Parichay Didwania Date: Tue, 4 Mar 2025 19:58:02 -0500 Subject: [PATCH 2/2] fix(helm): fail pdb if both are provided and only apply one of them --- charts/cluster-autoscaler/templates/pdb.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/charts/cluster-autoscaler/templates/pdb.yaml b/charts/cluster-autoscaler/templates/pdb.yaml index 75e00ebed4..3480db9726 100644 --- a/charts/cluster-autoscaler/templates/pdb.yaml +++ b/charts/cluster-autoscaler/templates/pdb.yaml @@ -1,5 +1,7 @@ {{- if .Values.podDisruptionBudget -}} -apiVersion: {{ template "podDisruptionBudget.apiVersion" . }} +{{- if and .Values.podDisruptionBudget.minAvailable .Values.podDisruptionBudget.maxUnavailable }} + {{- fail "Only one of podDisruptionBudget.minAvailable or podDisruptionBudget.maxUnavailable should be set." }} +{{- end }}apiVersion: {{ template "podDisruptionBudget.apiVersion" . }} kind: PodDisruptionBudget metadata: labels: @@ -10,7 +12,7 @@ spec: selector: matchLabels: {{ include "cluster-autoscaler.instance-name" . | indent 6 }} - {{- if .Values.podDisruptionBudget.minAvailable }} + {{- if and .Values.podDisruptionBudget.minAvailable (not .Values.podDisruptionBudget.maxUnavailable) }} minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} {{- end }} {{- if and .Values.podDisruptionBudget.maxUnavailable (not .Values.podDisruptionBudget.minAvailable) }}