Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for topologySpreadConstraints #273

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions charts/operator-wandb/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies:
version: 25.3.5
- name: etcd
repository: oci://registry-1.docker.io/bitnamicharts
version: 10.6.1
version: 10.7.1
- name: bufstream
repository: file://charts/bufstream
version: 0.3.1
Expand All @@ -56,5 +56,5 @@ dependencies:
- name: wandb-base
repository: file://../wandb-base
version: 0.1.1
digest: sha256:1eb284a2d6588f3e3d90293abb99f0e25b02fd62a87758f023d809879a82e31d
generated: "2024-12-06T11:08:12.69179-08:00"
digest: sha256:3c02029e1921428d7f45866291a8c42b79894505ee47864c54f34fcd847b2793
generated: "2024-12-18T18:29:20.054295+05:30"
2 changes: 1 addition & 1 deletion charts/operator-wandb/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: operator-wandb
description: A Helm chart for deploying W&B to Kubernetes
type: application
version: 0.21.8
version: 0.21.9
appVersion: 1.0.0
icon: https://wandb.ai/logo.svg

Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "app.labels" .))) | nindent 6 }}
{{- end }}
# Extend the pods shutdown grace period from the default of 30s to 60s.
# This goes in the pod template spec.
terminationGracePeriodSeconds: 60
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

common:
labels: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "console.labels" .))) | nindent 6 }}
{{- end }}
# Extend the pods shutdown grace period from the default of 30s to 60s.
# This goes in the pod template spec.
terminationGracePeriodSeconds: 60
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/console/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

service:
type: ClusterIP
annotations: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "executor.labels" .))) | nindent 6 }}
{{- end }}
# needed to ensure ensure Kafka consumers handle pod termination gracefully and avoid data loss
terminationGracePeriodSeconds: 60
containers:
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/executor/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

common:
labels: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "filestream.labels" .))) | nindent 6 }}
{{- end }}
# needed to ensure ensure Kafka consumers handle pod termination gracefully and avoid data loss
terminationGracePeriodSeconds: 60
containers:
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/filestream/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

common:
labels: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "flat-run-fields-updater.labels" .))) | nindent 6 }}
{{- end }}
# needed to ensure ensure Kafka consumers handle pod termination gracefully and avoid data loss
terminationGracePeriodSeconds: 60
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

common:
labels: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "mysql.labels" .))) | nindent 6 }}
{{- end }}
containers:
- name: mysql
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
{{- include "wandb.podSecurityContext" .Values.container.securityContext | nindent 10 }}
{{- include "wandb.containerSecurityContext" .Values.container.securityContext | nindent 10 }}
ports:
- name: mysql
containerPort: 3306
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/mysql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

resources:
requests:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "otelAgent.labels" .))) | nindent 6 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/otel/charts/agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

clusterRole:
annotations: {}
labels: {}
Expand Down
2 changes: 2 additions & 0 deletions charts/operator-wandb/charts/otel/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ daemonset:
deployment:
install: true
mode: "deployment"
topologySpreadConstraints:
enabled: false
presets:
receivers:
statsd: true
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/parquet/templates/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 10 }}
{{- include "wandb.priorityClassName" . | nindent 10 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 10 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "parquet.labels" .))) | nindent 10 }}
{{- end }}
containers:
- name: backfill-job
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "parquet.labels" .))) | nindent 6 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/parquet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ container:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false

topologySpreadConstraints:
enabled: false

resources:
# We usually recommend not to specify default resources and to leave this as a
# conscious choice for the user. This also increases chances charts run on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "weaveTrace.labels" .))) | nindent 6 }}
{{- end }}
{{- if not .Values.migration.useHook }}
initContainers:
- name: {{ include "weaveTraceMigrate.fullname" . }}
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/weave-trace/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

resources:
requests:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "weave.labels" .))) | nindent 6 }}
{{- end }}
containers:
- name: {{ include "weave.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/weave/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

resources:
# We usually recommend not to specify default resources and to leave this as a
# conscious choice for the user. This also increases chances charts run on
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/yace/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ spec:
{{- include "wandb.nodeSelector" . | nindent 6 }}
{{- include "wandb.priorityClassName" . | nindent 6 }}
{{- include "wandb.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
{{- if .Values.topologySpreadConstraints.enabled }}
{{- include "wandb.topologySpreadConstraints" (dict "matchLabels" (fromYaml (include "yace.labels" .))) | nindent 6 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/operator-wandb/charts/yace/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ container:
readOnlyRootFilesystem: false
privileged: false

topologySpreadConstraints:
enabled: false

deployment: {}

serviceAccount:
Expand Down
24 changes: 24 additions & 0 deletions charts/operator-wandb/templates/_pods.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,27 @@ securityContext:
{{- end }}
{{- end }}

{{/*
Return a simplified topologySpreadConstraints definition with dynamic labelSelector and matchLabels passed as a map.
*/}}
{{- define "wandb.topologySpreadConstraints" -}}
{{- $matchLabels := .matchLabels -}}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
{{- range $key, $value := $matchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
{{- range $key, $value := $matchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}

22 changes: 22 additions & 0 deletions charts/operator-wandb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ parquet:
tag: latest
envFrom:
"{{ .Release.Name }}-bucket-configmap": "configMapRef"
topologySpreadConstraints:
enabled: false

app:
install: true
Expand All @@ -216,6 +218,8 @@ app:
tag: latest
envFrom:
"{{ .Release.Name }}-bucket-configmap": "configMapRef"
topologySpreadConstraints:
enabled: false

nginx:
install: false
Expand All @@ -225,6 +229,8 @@ weave:
image:
repository: wandb/local
tag: latest
topologySpreadConstraints:
enabled: false

weave-trace:
install: false
Expand All @@ -233,12 +239,16 @@ weave-trace:
tag: latest
datadog:
enabled: false
topologySpreadConstraints:
enabled: false

console:
install: true
image:
repository: wandb/console
tag: latest
topologySpreadConstraints:
enabled: false

flat-run-fields-updater:
install: false
Expand All @@ -249,6 +259,8 @@ flat-run-fields-updater:
subscription: ""
envFrom:
"{{ .Release.Name }}-bucket-configmap": "configMapRef"
topologySpreadConstraints:
enabled: false

filestream:
install: false
Expand All @@ -259,6 +271,8 @@ filestream:
subscription: ""
envFrom:
"{{ .Release.Name }}-bucket-configmap": "configMapRef"
topologySpreadConstraints:
enabled: false

executor:
install: false
Expand All @@ -267,12 +281,16 @@ executor:
tag: latest
envFrom:
"{{ .Release.Name }}-bucket-configmap": "configMapRef"
topologySpreadConstraints:
enabled: false

mysql:
install: false
persistence:
size: 20Gi
storageClass: ""
topologySpreadConstraints:
enabled: false

yace:
install: false
Expand All @@ -283,6 +301,8 @@ yace:
prometheus.io/port: "5000"
prometheus.io/path: "/metrics"
prometheus.io/scheme: http
topologySpreadConstraints:
enabled: false

redis:
install: true
Expand Down Expand Up @@ -334,6 +354,8 @@ otel:
# promethus endpoint which causes duplicated metrics that get repoted.
deployment:
install: false
topologySpreadConstraints:
enabled: false

# # cannot use install because schema validation will fail.
# enabled: true
Expand Down
Loading