Skip to content

Commit

Permalink
Add support for topologySpreadConstraints to Helm Chart (apache#22712)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swalloow authored May 3, 2022
1 parent 427e14b commit 248ae9b
Show file tree
Hide file tree
Showing 21 changed files with 306 additions and 9 deletions.
2 changes: 2 additions & 0 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{{- $nodeSelector := or .Values.workers.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.workers.affinity .Values.affinity }}
{{- $tolerations := or .Values.workers.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.workers.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.workers) }}
apiVersion: v1
kind: Pod
Expand Down Expand Up @@ -88,6 +89,7 @@ spec:
nodeSelector: {{ toYaml $nodeSelector | nindent 4 }}
affinity: {{ toYaml $affinity | nindent 4 }}
tolerations: {{ toYaml $tolerations | nindent 4 }}
topologySpreadConstraints: {{ toYaml $topologySpreadConstraints | nindent 4 }}
serviceAccountName: {{ include "worker.serviceAccountName" . }}
volumes:
{{- if .Values.dags.persistence.enabled }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/cleanup/cleanup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- $nodeSelector := or .Values.cleanup.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.cleanup.affinity .Values.affinity }}
{{- $tolerations := or .Values.cleanup.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.cleanup.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.cleanup) }}
{{- if semverCompare ">= 1.21.x" (include "kubeVersion" .) }}
apiVersion: batch/v1
Expand Down Expand Up @@ -72,6 +73,8 @@ spec:
{{ toYaml $affinity | indent 12 }}
tolerations:
{{ toYaml $tolerations | indent 12 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 12 }}
serviceAccountName: {{ include "cleanup.serviceAccountName" . }}
{{- if or .Values.registry.secretName .Values.registry.connection }}
imagePullSecrets:
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/flower/flower-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{{- $nodeSelector := or .Values.flower.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.flower.affinity .Values.affinity }}
{{- $tolerations := or .Values.flower.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.flower.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.flower) }}
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -66,6 +67,8 @@ spec:
{{ toYaml $affinity | indent 8 }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
serviceAccountName: {{ include "flower.serviceAccountName" . }}
{{- if .Values.flower.priorityClassName }}
priorityClassName: {{ .Values.flower.priorityClassName }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/jobs/create-user-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- $nodeSelector := or .Values.createUserJob.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.createUserJob.affinity .Values.affinity }}
{{- $tolerations := or .Values.createUserJob.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.createUserJob.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.createUserJob) }}
apiVersion: batch/v1
kind: Job
Expand Down Expand Up @@ -74,6 +75,8 @@ spec:
{{ toYaml $affinity | indent 8 }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
serviceAccountName: {{ include "createUserJob.serviceAccountName" . }}
{{- if or .Values.registry.secretName .Values.registry.connection }}
imagePullSecrets:
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/jobs/migrate-database-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- $nodeSelector := or .Values.migrateDatabaseJob.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.migrateDatabaseJob.affinity .Values.affinity }}
{{- $tolerations := or .Values.migrateDatabaseJob.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.migrateDatabaseJob.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.migrateDatabaseJob) }}
apiVersion: batch/v1
kind: Job
Expand Down Expand Up @@ -74,6 +75,8 @@ spec:
{{ toYaml $affinity | indent 8 }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
serviceAccountName: {{ include "migrateDatabaseJob.serviceAccountName" . }}
{{- if or .Values.registry.secretName .Values.registry.connection }}
imagePullSecrets:
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/pgbouncer/pgbouncer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- $nodeSelector := or .Values.pgbouncer.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.pgbouncer.affinity .Values.affinity }}
{{- $tolerations := or .Values.pgbouncer.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.pgbouncer.topologySpreadConstraints .Values.topologySpreadConstraints }}
kind: Deployment
apiVersion: apps/v1
metadata:
Expand Down Expand Up @@ -68,6 +69,8 @@ spec:
{{ toYaml $affinity | indent 8 }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
serviceAccountName: {{ include "pgbouncer.serviceAccountName" . }}
securityContext:
runAsUser: {{ .Values.pgbouncer.uid }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/redis/redis-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- $nodeSelector := or .Values.redis.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.redis.affinity .Values.affinity }}
{{- $tolerations := or .Values.redis.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.redis.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "localSecurityContext" .Values.redis }}
kind: StatefulSet
apiVersion: apps/v1
Expand Down Expand Up @@ -63,6 +64,8 @@ spec:
{{ toYaml $affinity | indent 8 }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
serviceAccountName: {{ include "redis.serviceAccountName" . }}
{{- if or .Values.registry.secretName .Values.registry.connection }}
imagePullSecrets:
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
{{- $nodeSelector := or .Values.scheduler.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.scheduler.affinity .Values.affinity }}
{{- $tolerations := or .Values.scheduler.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.scheduler.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.scheduler) }}

kind: {{ if $stateful }}StatefulSet{{ else }}Deployment{{ end }}
Expand Down Expand Up @@ -110,6 +111,8 @@ spec:
{{- end }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
restartPolicy: Always
terminationGracePeriodSeconds: 10
serviceAccountName: {{ include "scheduler.serviceAccountName" . }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/statsd/statsd-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- $nodeSelector := or .Values.statsd.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.statsd.affinity .Values.affinity }}
{{- $tolerations := or .Values.statsd.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.statsd.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "localSecurityContext" .Values.statsd }}
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -66,6 +67,8 @@ spec:
{{ toYaml $affinity | indent 8 }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
serviceAccountName: {{ include "statsd.serviceAccountName" . }}
securityContext: {{ $securityContext | nindent 8 }}
restartPolicy: Always
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{{- $nodeSelector := or .Values.triggerer.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.triggerer.affinity .Values.affinity }}
{{- $tolerations := or .Values.triggerer.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.triggerer.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.triggerer) }}
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -93,6 +94,8 @@ spec:
{{- end }}
tolerations:
{{- toYaml $tolerations | nindent 8 }}
topologySpreadConstraints:
{{- toYaml $topologySpreadConstraints | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.triggerer.terminationGracePeriodSeconds }}
restartPolicy: Always
serviceAccountName: {{ include "triggerer.serviceAccountName" . }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/webserver/webserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{{- $nodeSelector := or .Values.webserver.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.webserver.affinity .Values.affinity }}
{{- $tolerations := or .Values.webserver.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.webserver.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.webserver) }}
kind: Deployment
apiVersion: apps/v1
Expand Down Expand Up @@ -107,6 +108,8 @@ spec:
{{- end }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
restartPolicy: Always
securityContext: {{ $securityContext | nindent 8 }}
{{- if or .Values.registry.secretName .Values.registry.connection }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{{- $nodeSelector := or .Values.workers.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.workers.affinity .Values.affinity }}
{{- $tolerations := or .Values.workers.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.workers.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowSecurityContext" (list . .Values.workers) }}
kind: {{ if $persistence }}StatefulSet{{ else }}Deployment{{ end }}
apiVersion: apps/v1
Expand Down Expand Up @@ -103,6 +104,8 @@ spec:
{{- end }}
tolerations:
{{ toYaml $tolerations | indent 8 }}
topologySpreadConstraints:
{{ toYaml $topologySpreadConstraints | indent 8 }}
{{- if .Values.workers.hostAliases }}
hostAliases:
{{ toYaml .Values.workers.hostAliases | indent 8 }}
Expand Down
Loading

0 comments on commit 248ae9b

Please sign in to comment.