diff --git a/chart/templates/configmaps/configmap.yaml b/chart/templates/configmaps/configmap.yaml index 2cf45020d6447..3359e44258409 100644 --- a/chart/templates/configmaps/configmap.yaml +++ b/chart/templates/configmaps/configmap.yaml @@ -50,6 +50,9 @@ data: airflow_local_settings.py: | {{- if .Values.scheduler.airflowLocalSettings }} {{ .Values.scheduler.airflowLocalSettings | nindent 4 }} +{{- else if .Values.podMutation.enabled }} + airflow_local_settings.py: | + {{ tpl .Values.podMutation.podMutationHookTpl . | nindent 4 }} {{- end }} {{- if and .Values.dags.gitSync.enabled .Values.dags.gitSync.knownHosts }} known_hosts: | diff --git a/chart/templates/scheduler/scheduler-deployment.yaml b/chart/templates/scheduler/scheduler-deployment.yaml index 61dcadecbb109..70842327ea13d 100644 --- a/chart/templates/scheduler/scheduler-deployment.yaml +++ b/chart/templates/scheduler/scheduler-deployment.yaml @@ -147,7 +147,7 @@ spec: mountPath: {{ template "airflow_config_path" . }} subPath: airflow.cfg readOnly: true -{{- if .Values.scheduler.airflowLocalSettings }} +{{- if or ( .Values.scheduler.airflowLocalSettings ) ( .Values.podMutation.enabled ) }} - name: config mountPath: {{ template "airflow_local_setting_path" . }} subPath: airflow_local_settings.py diff --git a/chart/values.yaml b/chart/values.yaml index 091a0c9bd5f39..ecdf06999d712 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -617,6 +617,42 @@ quotas: {} # Define default/max/min values for pods and containers in namespace limits: [] +# Config Settings for pod_mutation_hook +# podMutation values will not apply if `scheduler.airflowLocalSettings` have been modified +podMutation: + enabled: false + # You can just add `tolerations` and `affinity` below + # or define this podMutationHookTpl however you like. + # Anything can be templated here since it is using `tpl` helm function + # If using Airflow < 2.0.0 use following mutation hook: + # from airflow.contrib.kubernetes.pod import Pod + # def pod_mutation_hook(pod: Pod): + # pod.tolerations += {{ toJson .Values.podMutation.tolerations }} + # pod.affinity.update({{ toJson .Values.podMutation.affinity }}) + podMutationHookTpl: | + # Airflow >= 2.0.0 pod_mutation_hook + def pod_mutation_hook(pod): # type pod: k8s.V1Pod + pod.spec.tolerations = {{ toJson .Values.podMutation.tolerations }} + pod.spec.affinity = {{ toJson .Values.podMutation.affinity }} + + # Any pods spun up using KubernetesExecutor or KubernetesPodOperator will contain these tolerations. + tolerations: [] + # - key: "dynamic-pods" + # operator: "Equal" + # value: "true" + # effect: "NoSchedule" + + # Pods spun up would land in the node that matches the affinity + affinity: {} + # nodeAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # nodeSelectorTerms: + # - matchExpressions: + # - key: "company.io/dynamic-pods" + # operator: In + # values: + # - "true" + # This runs as a CronJob to cleanup old pods. cleanup: enabled: false