From 5ec1982debabf1ec038c8af66c5c22e1752342ce Mon Sep 17 00:00:00 2001 From: fe80 Date: Wed, 27 Aug 2025 09:48:45 +0200 Subject: [PATCH] feat: add topologySpreadConstraints Signed-off-by: fe80 --- charts/mageai/templates/deployment.yaml | 11 ++++++++ charts/mageai/templates/scheduler.yaml | 11 ++++++++ charts/mageai/templates/webservice.yaml | 11 ++++++++ charts/mageai/values.yaml | 35 +++++++++++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/charts/mageai/templates/deployment.yaml b/charts/mageai/templates/deployment.yaml index 56e1c9b..52664fb 100644 --- a/charts/mageai/templates/deployment.yaml +++ b/charts/mageai/templates/deployment.yaml @@ -139,6 +139,17 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := . }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + {{- include "mageai.selectorLabels" $ | nindent 14 }} + {{- end }} + {{- end }} + {{- end }} volumes: {{- if .Values.volumes }} {{- toYaml .Values.volumes | nindent 8 }} diff --git a/charts/mageai/templates/scheduler.yaml b/charts/mageai/templates/scheduler.yaml index 43fea7c..d2c832f 100644 --- a/charts/mageai/templates/scheduler.yaml +++ b/charts/mageai/templates/scheduler.yaml @@ -110,6 +110,17 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.scheduler.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := . }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + {{- include "mageai.schedulerSelectorLabels" $ | nindent 14 }} + {{- end }} + {{- end }} + {{- end }} volumes: {{- if .Values.volumes }} {{- toYaml .Values.volumes | nindent 8 }} diff --git a/charts/mageai/templates/webservice.yaml b/charts/mageai/templates/webservice.yaml index 728e557..f920354 100644 --- a/charts/mageai/templates/webservice.yaml +++ b/charts/mageai/templates/webservice.yaml @@ -138,6 +138,17 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.webServer.topologySpreadConstraints }} + topologySpreadConstraints: + {{- range $constraint := . }} + - {{ toYaml $constraint | nindent 10 | trim }} + {{- if not $constraint.labelSelector }} + labelSelector: + matchLabels: + {{- include "mageai.selectorLabels" $ | nindent 14 }} + {{- end }} + {{- end }} + {{- end }} volumes: {{- if .Values.volumes }} {{- toYaml .Values.volumes | nindent 8 }} diff --git a/charts/mageai/values.yaml b/charts/mageai/values.yaml index 7830b97..b9ecb32 100644 --- a/charts/mageai/values.yaml +++ b/charts/mageai/values.yaml @@ -25,6 +25,18 @@ scheduler: # maxReplicas: 10 # targetCPUUtilizationPercentage: 50 + topologySpreadConstraints: [] + # - maxSkew: 1 + # topologyKey: topology.kubernetes.io/zone + # whenUnsatisfiable: ScheduleAnyway + # matchLabelKeys: + # - pod-template-hash + # - maxSkew: 1 + # topologyKey: kubernetes.io/hostname + # whenUnsatisfiable: DoNotSchedule + # matchLabelKeys: + # - pod-template-hash + # Effective if standaloneScheduler is true webServer: replicaCount: 1 @@ -44,6 +56,17 @@ webServer: # minReplicas: 1 # maxReplicas: 10 # targetCPUUtilizationPercentage: 50 + topologySpreadConstraints: [] + # - maxSkew: 1 + # topologyKey: topology.kubernetes.io/zone + # whenUnsatisfiable: ScheduleAnyway + # matchLabelKeys: + # - pod-template-hash + # - maxSkew: 1 + # topologyKey: kubernetes.io/hostname + # whenUnsatisfiable: DoNotSchedule + # matchLabelKeys: + # - pod-template-hash # Enable Postgres as the DB postgresql: @@ -174,6 +197,18 @@ nodeSelector: {} tolerations: [] +topologySpreadConstraints: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: ScheduleAnyway + matchLabelKeys: + - pod-template-hash + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + matchLabelKeys: + - pod-template-hash + affinity: {} extraVolumeMounts: