File tree Expand file tree Collapse file tree 6 files changed +39
-1
lines changed Expand file tree Collapse file tree 6 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ const Env = z.object({
9090 KUBERNETES_MEMORY_REQUEST_MIN_GB : z . coerce . number ( ) . min ( 0 ) . default ( 0 ) ,
9191 KUBERNETES_MEMORY_REQUEST_RATIO : z . coerce . number ( ) . min ( 0 ) . max ( 1 ) . default ( 1 ) , // Ratio of memory limit, so 1 = 100% of memory limit
9292 KUBERNETES_MEMORY_OVERHEAD_GB : z . coerce . number ( ) . min ( 0 ) . optional ( ) , // Optional memory overhead to add to the limit in GB
93+ KUBERNETES_TOPOLOGY_SPREAD_CONSTRAINTS : z . string ( ) . optional ( ) , // JSON string
9394
9495 // Placement tags settings
9596 PLACEMENT_TAGS_ENABLED : BoolEnv . default ( false ) ,
Original file line number Diff line number Diff line change @@ -56,6 +56,22 @@ export class KubernetesWorkloadManager implements WorkloadManager {
5656 } ;
5757 }
5858
59+ private parseTopologySpreadConstraints ( ) : k8s . V1TopologySpreadConstraint [ ] | null {
60+ if ( ! env . KUBERNETES_TOPOLOGY_SPREAD_CONSTRAINTS ) {
61+ return null ;
62+ }
63+
64+ try {
65+ return JSON . parse ( env . KUBERNETES_TOPOLOGY_SPREAD_CONSTRAINTS ) ;
66+ } catch ( error ) {
67+ this . logger . error ( "[KubernetesWorkloadManager] Failed to parse topology spread constraints" , {
68+ error : error instanceof Error ? error . message : String ( error ) ,
69+ raw : env . KUBERNETES_TOPOLOGY_SPREAD_CONSTRAINTS ,
70+ } ) ;
71+ return null ;
72+ }
73+ }
74+
5975 private stripImageDigest ( imageRef : string ) : string {
6076 if ( ! env . KUBERNETES_STRIP_IMAGE_DIGEST ) {
6177 return imageRef ;
@@ -270,6 +286,8 @@ export class KubernetesWorkloadManager implements WorkloadManager {
270286 }
271287
272288 get #defaultPodSpec( ) : Omit < k8s . V1PodSpec , "containers" > {
289+ const topologySpreadConstraints = this . parseTopologySpreadConstraints ( ) ;
290+
273291 return {
274292 restartPolicy : "Never" ,
275293 automountServiceAccountToken : false ,
@@ -281,6 +299,7 @@ export class KubernetesWorkloadManager implements WorkloadManager {
281299 } ,
282300 }
283301 : { } ) ,
302+ ...( topologySpreadConstraints ? { topologySpreadConstraints } : { } ) ,
284303 } ;
285304 }
286305
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ apiVersion: v2
22name : trigger
33description : The official Trigger.dev Helm chart
44type : application
5- version : 4.0.1
5+ version : 4.0.2
66appVersion : v4.0.4
77home : https://trigger.dev
88sources :
Original file line number Diff line number Diff line change @@ -184,6 +184,10 @@ spec:
184184 value : {{ default "10Gi" .Values.supervisor.config.kubernetes.ephemeralStorageSizeLimit | quote }}
185185 - name : KUBERNETES_EPHEMERAL_STORAGE_SIZE_REQUEST
186186 value : {{ default "2Gi" .Values.supervisor.config.kubernetes.ephemeralStorageSizeRequest | quote }}
187+ {{- with .Values.supervisor.config.kubernetes.topologySpreadConstraints }}
188+ - name : KUBERNETES_WORKER_TOPOLOGY_SPREAD_CONSTRAINTS
189+ value : {{ tpl (toYaml .) $ | toJson | quote }}
190+ {{- end }}
187191 # Pod cleaner configuration
188192 - name : POD_CLEANER_ENABLED
189193 value : {{ .Values.supervisor.config.podCleaner.enabled | quote }}
@@ -272,6 +276,10 @@ spec:
272276 tolerations :
273277 {{- toYaml . | nindent 8 }}
274278 {{- end }}
279+ {{- with .Values.supervisor.topologySpreadConstraints }}
280+ topologySpreadConstraints :
281+ {{- tpl (toYaml .) $ | nindent 8 }}
282+ {{- end }}
275283---
276284apiVersion : v1
277285kind : Service
Original file line number Diff line number Diff line change @@ -419,6 +419,10 @@ spec:
419419 tolerations :
420420 {{- toYaml . | nindent 8 }}
421421 {{- end }}
422+ {{- with .Values.webapp.topologySpreadConstraints }}
423+ topologySpreadConstraints :
424+ {{- tpl (toYaml .) $ | nindent 8 }}
425+ {{- end }}
422426---
423427apiVersion : v1
424428kind : Service
Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ webapp:
6969 nodeSelector : {}
7070 tolerations : []
7171 affinity : {}
72+ # Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template
73+ topologySpreadConstraints : []
7274
7375 logLevel : " info"
7476 gracefulShutdownTimeout : 1000
@@ -263,6 +265,8 @@ supervisor:
263265 workerNodetypeLabel : " " # When set, runs will only be scheduled on nodes with "nodetype=<label>"
264266 ephemeralStorageSizeLimit : " " # Default: 10Gi
265267 ephemeralStorageSizeRequest : " " # Default: 2Gi´
268+ # Topology Spread Constraints for worker pods created by the supervisor. Evaluated as a template
269+ topologySpreadConstraints : []
266270 podCleaner :
267271 enabled : true
268272 batchSize : 100
@@ -353,6 +357,8 @@ supervisor:
353357 nodeSelector : {}
354358 tolerations : []
355359 affinity : {}
360+ # Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template
361+ topologySpreadConstraints : []
356362
357363# PostgreSQL configuration
358364# Subchart: https://github.com/bitnami/charts/tree/main/bitnami/postgresql
You can’t perform that action at this time.
0 commit comments