Skip to content

Commit

Permalink
feat: allow deploying worker groups as statefulsets
Browse files Browse the repository at this point in the history
  • Loading branch information
invakid404 committed Oct 8, 2024
1 parent 8cc7afc commit dead283
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
13 changes: 13 additions & 0 deletions charts/windmill/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Validate controller kind, defaulting to "Deployment"
*/}}
{{- define "validateControllerKind" -}}
{{- $validTypes := list "Deployment" "StatefulSet" -}}
{{- $inputType := default "Deployment" . -}}
{{- if has $inputType $validTypes -}}
{{ $inputType }}
{{- else -}}
{{- fail (printf "Invalid controller type: %s. Must be either Deployment or StatefulSet" $inputType) -}}
{{- end -}}
{{- end -}}
17 changes: 16 additions & 1 deletion charts/windmill/templates/worker-groups.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- range $v := .Values.windmill.workerGroups }}
{{ if and $v.replicas (gt (int $v.replicas) 0)}}
---
{{- $controllerType := include "validateControllerKind" $v.controller }}
apiVersion: apps/v1
kind: Deployment
kind: {{ $controllerType }}
metadata:
name: windmill-workers-{{ $v.name }}
labels:
Expand All @@ -14,11 +15,19 @@ metadata:
workerGroup: {{ $v.name }}
spec:
replicas: {{ $v.replicas }}
{{- if eq $controllerType "Deployment" }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 3
maxUnavailable: 0
{{- else if eq $controllerType "StatefulSet" }}
serviceName: windmill-workers-{{ $v.name }}
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
{{- end }}
selector:
matchLabels:
app: windmill-workers
Expand Down Expand Up @@ -172,5 +181,11 @@ spec:
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- if eq $controllerType "StatefulSet" }}
{{- if $v.volumeClaimTemplates }}
volumeClaimTemplates:
{{- toYaml $v.volumeClaimTemplates | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 19 additions & 3 deletions charts/windmill/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ windmill:
# workers configuration
# The default worker group
- name: "default"
# -- Controller to use. Valid options are "Deployment" and "StatefulSet"
controller: "Deployment"

replicas: 3
# -- Annotations to apply to the pods
annotations: {}
Expand All @@ -99,7 +102,6 @@ windmill:
# -- Security context to apply to the pod
containerSecurityContext: {}


# -- Affinity rules to apply to the pods
affinity: {}

Expand All @@ -120,10 +122,16 @@ windmill:
volumes: []
volumeMounts: []

# -- Volume claim templates. Only applies when controller is "StatefulSet"
volumeClaimTemplates: []

# -- command override
command: []

- name: "native"
# -- Controller to use. Valid options are "Deployment" and "StatefulSet"
controller: "Deployment"

replicas: 1
# -- Annotations to apply to the pods
annotations: {}
Expand All @@ -146,7 +154,6 @@ windmill:
# -- Security context to apply to the pod
containerSecurityContext: {}


# -- Affinity rules to apply to the pods
affinity: {}

Expand All @@ -170,7 +177,13 @@ windmill:
volumes: []
volumeMounts: []

# -- Volume claim templates. Only applies when controller is "StatefulSet"
volumeClaimTemplates: []

- name: "gpu"
# -- Controller to use. Valid options are "Deployment" and "StatefulSet"
controller: "Deployment"

replicas: 0
# -- Annotations to apply to the pods
annotations: {}
Expand All @@ -193,7 +206,6 @@ windmill:
# -- Security context to apply to the pod
containerSecurityContext: {}


# -- Affinity rules to apply to the pods
affinity: {}

Expand All @@ -210,8 +222,12 @@ windmill:
volumes: []
volumeMounts: []

# -- Volume claim templates. Only applies when controller is "StatefulSet"
volumeClaimTemplates: []

# -- command override
command: []

# app configuration
app:
# -- Annotations to apply to the pods
Expand Down

0 comments on commit dead283

Please sign in to comment.