From 240c6a3adaefdc40631e95c6d550d53669987fd0 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Mon, 17 Aug 2026 12:17:17 -0700 Subject: [PATCH] feat: multi-az flag --- Chart.yaml | 4 ++-- README.md | 14 ++++++++++++++ scripts/schema-overrides.yaml | 6 ++++++ templates/deployment.yaml | 12 +++++++++++- test/values-multi-az.yaml | 4 ++++ values.yaml | 6 ++++++ 6 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 test/values-multi-az.yaml diff --git a/Chart.yaml b/Chart.yaml index cfce3cb..c3e2816 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v1 name: pgdog -version: v0.74 -appVersion: "0.1.52" +version: v0.75 +appVersion: "v0.1.52" diff --git a/README.md b/README.md index 2a58355..0d8ab57 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,20 @@ podAntiAffinity: type: soft # "soft" (preferred) or "hard" (required) ``` +#### Multi-AZ + +Spread replicas evenly across availability zones with a maximum skew of one: + +```yaml +multiAz: + enabled: true + whenUnsatisfiable: ScheduleAnyway +``` + +This uses the `topology.kubernetes.io/zone` node label. Set +`whenUnsatisfiable` to `DoNotSchedule` to make the constraint strict. Additional +constraints can be set with `topologySpreadConstraints`. + ### Config Change Restarts By default, ConfigMap changes are not automatically picked up by diff --git a/scripts/schema-overrides.yaml b/scripts/schema-overrides.yaml index 6638e52..f51a912 100644 --- a/scripts/schema-overrides.yaml +++ b/scripts/schema-overrides.yaml @@ -462,6 +462,12 @@ topologySpreadConstraints: description: Topology spread constraints items: type: object +multiAz.enabled: + type: boolean + description: Enable spreading pods evenly across availability zones +multiAz.whenUnsatisfiable: + enum: ["DoNotSchedule", "ScheduleAnyway"] + description: Action to take when the zone spread constraint cannot be satisfied # --- Pod anti-affinity --- podAntiAffinity.enabled: diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 5bb7089..1a244e9 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -279,9 +279,19 @@ spec: {{- end }} {{- end }} {{- end }} - {{- with .Values.topologySpreadConstraints }} + {{- if or .Values.multiAz.enabled .Values.topologySpreadConstraints }} topologySpreadConstraints: + {{- if .Values.multiAz.enabled }} + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: {{ .Values.multiAz.whenUnsatisfiable }} + labelSelector: + matchLabels: + {{- include "pgdog.selectorLabels" . | nindent 14 }} + {{- end }} + {{- with .Values.topologySpreadConstraints }} {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- if and .Values.statefulSet.enabled .Values.statefulSet.walPvc.enabled }} volumeClaimTemplates: diff --git a/test/values-multi-az.yaml b/test/values-multi-az.yaml new file mode 100644 index 0000000..cc65bb8 --- /dev/null +++ b/test/values-multi-az.yaml @@ -0,0 +1,4 @@ +# Test multi-AZ topology spread rendering +multiAz: + enabled: true + whenUnsatisfiable: DoNotSchedule diff --git a/values.yaml b/values.yaml index 4437501..f218531 100644 --- a/values.yaml +++ b/values.yaml @@ -397,6 +397,12 @@ topologySpreadConstraints: [] # matchLabels: # app: pgdog +# multiAz spreads pods evenly across availability zones with a maximum skew of 1. +multiAz: + enabled: true + # Valid values: DoNotSchedule, ScheduleAnyway + whenUnsatisfiable: ScheduleAnyway + # podAntiAffinity enables default anti-affinity rules to spread pods # across nodes # Set to true for automatic pod anti-affinity configuration