From dd7105ddd3216adfe87a7bec96f8179773da5de7 Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Fri, 20 Sep 2024 22:01:24 +0200 Subject: [PATCH] Added support for relative values in scheduling.minAvailable --- .../ci/relative-min-available-values.yaml | 10 ++++++++++ charts/generic-service/templates/pdb.yaml | 2 +- charts/generic-service/values.schema.json | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 charts/generic-service/ci/relative-min-available-values.yaml diff --git a/charts/generic-service/ci/relative-min-available-values.yaml b/charts/generic-service/ci/relative-min-available-values.yaml new file mode 100644 index 0000000..2297a22 --- /dev/null +++ b/charts/generic-service/ci/relative-min-available-values.yaml @@ -0,0 +1,10 @@ +# Relative minimum availability test + +image: + repository: jwilder/whoami + tag: latest + +replicas: 3 + +scheduling: + minAvailable: 50% diff --git a/charts/generic-service/templates/pdb.yaml b/charts/generic-service/templates/pdb.yaml index 4846cec..f46480e 100644 --- a/charts/generic-service/templates/pdb.yaml +++ b/charts/generic-service/templates/pdb.yaml @@ -1,4 +1,4 @@ -{{- if and (gt .Values.scheduling.minAvailable 0.0) (lt .Values.scheduling.minAvailable .Values.replicas) }} +{{- if or (kindIs "string" .Values.scheduling.minAvailable) (and (gt .Values.scheduling.minAvailable 0.0) (lt .Values.scheduling.minAvailable .Values.replicas)) }} apiVersion: policy/v1 kind: PodDisruptionBudget diff --git a/charts/generic-service/values.schema.json b/charts/generic-service/values.schema.json index 1b5c796..eeb3f80 100644 --- a/charts/generic-service/values.schema.json +++ b/charts/generic-service/values.schema.json @@ -587,7 +587,7 @@ "description": "How to spread replicas across nodes" }, "minAvailable": { - "type": "integer", + "type": ["integer", "string"], "default": 1, "description": "Minimum number of instances to keep running during cluster maintenance (only applied if this value is smaller than replicas)" }