diff --git a/CHANGELOG.md b/CHANGELOG.md index 2410629..96a81d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ Workbench or REST API. - Added `publishNotReadyAddresses` to `service`, `headlessService`, `proxy.service` and `proxy.headlessService`. Headless services default to `true` to allow cluster nodes to communicate before readiness probes pass, enabling proper startup sequencing during rolling upgrades. +- Added `topologySpreadConstraintsPreset` for GraphDB and proxy StatefulSets. When enabled, automatically + configures two topology spread constraints that spread pods across availability zones + (`topology.kubernetes.io/zone`) and nodes (`kubernetes.io/hostname`). Simplifies cloud deployments on + AWS/Azure/GCP with multiple availability zones. Explicit `topologySpreadConstraints` takes precedence + when set. ## Version 12.4.0 diff --git a/README.md b/README.md index 7b34aec..a6076c7 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,9 @@ IMPORTANT: This is generated by helm-docs, do not attempt modifying it on hand a | proxy.terminationGracePeriodSeconds | int | `30` | | | proxy.tolerations | list | `[]` | | | proxy.topologySpreadConstraints | list | `[]` | | +| proxy.topologySpreadConstraintsPreset.enabled | bool | `false` | | +| proxy.topologySpreadConstraintsPreset.maxSkew | int | `1` | | +| proxy.topologySpreadConstraintsPreset.whenUnsatisfiable | string | `"ScheduleAnyway"` | | | proxy.updateStrategy.type | string | `"RollingUpdate"` | | | readinessProbe.httpGet.path | string | `"/protocol"` | | | readinessProbe.httpGet.port | string | `"http"` | | @@ -690,6 +693,9 @@ IMPORTANT: This is generated by helm-docs, do not attempt modifying it on hand a | terminationGracePeriodSeconds | int | `120` | | | tolerations | list | `[]` | | | topologySpreadConstraints | list | `[]` | | +| topologySpreadConstraintsPreset.enabled | bool | `false` | | +| topologySpreadConstraintsPreset.maxSkew | int | `1` | | +| topologySpreadConstraintsPreset.whenUnsatisfiable | string | `"ScheduleAnyway"` | | | updateStrategy.type | string | `"RollingUpdate"` | | ## Troubleshooting diff --git a/templates/graphdb/statefulset.yaml b/templates/graphdb/statefulset.yaml index 14aa810..4c8635b 100644 --- a/templates/graphdb/statefulset.yaml +++ b/templates/graphdb/statefulset.yaml @@ -264,8 +264,28 @@ spec: {{- with .Values.tolerations }} tolerations: {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} - {{- with .Values.topologySpreadConstraints }} - topologySpreadConstraints: {{- tpl (toYaml .) $ | nindent 8 }} + {{- if or .Values.topologySpreadConstraints .Values.topologySpreadConstraintsPreset.enabled }} + topologySpreadConstraints: + {{- if .Values.topologySpreadConstraints }} + {{- tpl (toYaml .Values.topologySpreadConstraints) $ | nindent 8 }} + {{- else }} + - labelSelector: + matchLabels: + {{- include "graphdb.selectorLabels" . | nindent 14 }} + matchLabelKeys: + - pod-template-hash + topologyKey: topology.kubernetes.io/zone + maxSkew: {{ .Values.topologySpreadConstraintsPreset.maxSkew }} + whenUnsatisfiable: {{ .Values.topologySpreadConstraintsPreset.whenUnsatisfiable }} + - labelSelector: + matchLabels: + {{- include "graphdb.selectorLabels" . | nindent 14 }} + matchLabelKeys: + - pod-template-hash + topologyKey: kubernetes.io/hostname + maxSkew: {{ .Values.topologySpreadConstraintsPreset.maxSkew }} + whenUnsatisfiable: {{ .Values.topologySpreadConstraintsPreset.whenUnsatisfiable }} + {{- end }} {{- end }} {{- with .Values.podSecurityContext }} securityContext: {{- toYaml . | nindent 8 }} diff --git a/templates/proxy/statefulset.yaml b/templates/proxy/statefulset.yaml index 09458ea..2c6b732 100644 --- a/templates/proxy/statefulset.yaml +++ b/templates/proxy/statefulset.yaml @@ -227,8 +227,28 @@ spec: {{- with .Values.proxy.tolerations }} tolerations: {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} - {{- with .Values.proxy.topologySpreadConstraints }} - topologySpreadConstraints: {{- tpl (toYaml .) $ | nindent 8 }} + {{- if or .Values.proxy.topologySpreadConstraints .Values.proxy.topologySpreadConstraintsPreset.enabled }} + topologySpreadConstraints: + {{- if .Values.proxy.topologySpreadConstraints }} + {{- tpl (toYaml .Values.proxy.topologySpreadConstraints) $ | nindent 8 }} + {{- else }} + - labelSelector: + matchLabels: + {{- include "graphdb-proxy.selectorLabels" . | nindent 14 }} + matchLabelKeys: + - pod-template-hash + topologyKey: topology.kubernetes.io/zone + maxSkew: {{ .Values.proxy.topologySpreadConstraintsPreset.maxSkew }} + whenUnsatisfiable: {{ .Values.proxy.topologySpreadConstraintsPreset.whenUnsatisfiable }} + - labelSelector: + matchLabels: + {{- include "graphdb-proxy.selectorLabels" . | nindent 14 }} + matchLabelKeys: + - pod-template-hash + topologyKey: kubernetes.io/hostname + maxSkew: {{ .Values.proxy.topologySpreadConstraintsPreset.maxSkew }} + whenUnsatisfiable: {{ .Values.proxy.topologySpreadConstraintsPreset.whenUnsatisfiable }} + {{- end }} {{- end }} {{- with .Values.proxy.podSecurityContext }} securityContext: {{- toYaml . | nindent 8 }} diff --git a/values.yaml b/values.yaml index e87a720..b207f24 100644 --- a/values.yaml +++ b/values.yaml @@ -1023,6 +1023,18 @@ tolerations: [] # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ topologySpreadConstraints: [] +# Default topology spread constraints preset ensuring GraphDB pods are spread across availability zones and nodes. +# When enabled and topologySpreadConstraints is empty, two constraints are generated: +# - Spread across availability zones (topology.kubernetes.io/zone) +# - Spread across nodes (kubernetes.io/hostname) +# Useful for cloud deployments on AWS/Azure/GCP with multiple availability zones. +# Note: topologySpreadConstraints takes precedence over this preset when set. +# Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ +topologySpreadConstraintsPreset: + enabled: false + maxSkew: 1 + whenUnsatisfiable: ScheduleAnyway + ########################## # Resource Configuration # ########################## @@ -1641,6 +1653,18 @@ proxy: # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ topologySpreadConstraints: [] + # Default topology spread constraints preset ensuring GraphDB proxy pods are spread across availability zones and nodes. + # When enabled and topologySpreadConstraints is empty, two constraints are generated: + # - Spread across availability zones (topology.kubernetes.io/zone) + # - Spread across nodes (kubernetes.io/hostname) + # Useful for cloud deployments on AWS/Azure/GCP with multiple availability zones. + # Note: topologySpreadConstraints takes precedence over this preset when set. + # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ + topologySpreadConstraintsPreset: + enabled: false + maxSkew: 1 + whenUnsatisfiable: ScheduleAnyway + ########################## # Resource Configuration # ##########################