triggerer-deployment.yaml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. ################################
  18. ## Airflow Triggerer Deployment
  19. #################################
  20. {{- if semverCompare ">=2.2.0" .Values.airflowVersion }}
  21. {{- if .Values.triggerer.enabled }}
  22. {{- $nodeSelector := or .Values.triggerer.nodeSelector .Values.nodeSelector }}
  23. {{- $affinity := or .Values.triggerer.affinity .Values.affinity }}
  24. {{- $tolerations := or .Values.triggerer.tolerations .Values.tolerations }}
  25. {{- $topologySpreadConstraints := or .Values.triggerer.topologySpreadConstraints .Values.topologySpreadConstraints }}
  26. {{- $securityContext := include "airflowSecurityContext" (list . .Values.triggerer) }}
  27. kind: Deployment
  28. apiVersion: apps/v1
  29. metadata:
  30. name: {{ .Release.Name }}-triggerer
  31. labels:
  32. tier: airflow
  33. component: triggerer
  34. release: {{ .Release.Name }}
  35. chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  36. heritage: {{ .Release.Service }}
  37. {{- with .Values.labels }}
  38. {{- toYaml . | nindent 4 }}
  39. {{- end }}
  40. spec:
  41. replicas: {{ .Values.triggerer.replicas }}
  42. selector:
  43. matchLabels:
  44. tier: airflow
  45. component: triggerer
  46. release: {{ .Release.Name }}
  47. {{- if .Values.triggerer.strategy }}
  48. strategy:
  49. {{- toYaml .Values.triggerer.strategy | nindent 4 }}
  50. {{- end }}
  51. template:
  52. metadata:
  53. labels:
  54. tier: airflow
  55. component: triggerer
  56. release: {{ .Release.Name }}
  57. {{- with .Values.labels }}
  58. {{- toYaml . | nindent 8 }}
  59. {{- end }}
  60. annotations:
  61. checksum/metadata-secret: {{ include (print $.Template.BasePath "/secrets/metadata-connection-secret.yaml") . | sha256sum }}
  62. checksum/pgbouncer-config-secret: {{ include (print $.Template.BasePath "/secrets/pgbouncer-config-secret.yaml") . | sha256sum }}
  63. checksum/airflow-config: {{ include (print $.Template.BasePath "/configmaps/configmap.yaml") . | sha256sum }}
  64. checksum/extra-configmaps: {{ include (print $.Template.BasePath "/configmaps/extra-configmaps.yaml") . | sha256sum }}
  65. checksum/extra-secrets: {{ include (print $.Template.BasePath "/secrets/extra-secrets.yaml") . | sha256sum }}
  66. {{- if .Values.triggerer.safeToEvict }}
  67. cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
  68. {{- end }}
  69. {{- if .Values.airflowPodAnnotations }}
  70. {{- toYaml .Values.airflowPodAnnotations | nindent 8 }}
  71. {{- end }}
  72. {{- if .Values.triggerer.podAnnotations }}
  73. {{- toYaml .Values.triggerer.podAnnotations | nindent 8 }}
  74. {{- end }}
  75. spec:
  76. {{- if .Values.triggerer.priorityClassName }}
  77. priorityClassName: {{ .Values.triggerer.priorityClassName }}
  78. {{- end }}
  79. nodeSelector:
  80. {{- toYaml $nodeSelector | nindent 8 }}
  81. affinity:
  82. {{- if $affinity }}
  83. {{- toYaml $affinity | nindent 8 }}
  84. {{- else }}
  85. podAntiAffinity:
  86. preferredDuringSchedulingIgnoredDuringExecution:
  87. - podAffinityTerm:
  88. labelSelector:
  89. matchLabels:
  90. component: triggerer
  91. topologyKey: kubernetes.io/hostname
  92. weight: 100
  93. {{- end }}
  94. tolerations:
  95. {{- toYaml $tolerations | nindent 8 }}
  96. topologySpreadConstraints:
  97. {{- toYaml $topologySpreadConstraints | nindent 8 }}
  98. terminationGracePeriodSeconds: {{ .Values.triggerer.terminationGracePeriodSeconds }}
  99. restartPolicy: Always
  100. serviceAccountName: {{ include "triggerer.serviceAccountName" . }}
  101. securityContext: {{ $securityContext | nindent 8 }}
  102. {{- if or .Values.registry.secretName .Values.registry.connection }}
  103. imagePullSecrets:
  104. - name: {{ template "registry_secret" . }}
  105. {{- end }}
  106. initContainers:
  107. {{- if .Values.triggerer.waitForMigrations.enabled }}
  108. - name: wait-for-airflow-migrations
  109. resources:
  110. {{- toYaml .Values.triggerer.resources | nindent 12 }}
  111. image: {{ template "airflow_image_for_migrations" . }}
  112. imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
  113. volumeMounts:
  114. - name: config
  115. mountPath: {{ template "airflow_config_path" . }}
  116. subPath: airflow.cfg
  117. readOnly: true
  118. args:
  119. {{- include "wait-for-migrations-command" . | nindent 10 }}
  120. envFrom:
  121. {{- include "custom_airflow_environment_from" . | default "\n []" | nindent 10 }}
  122. env:
  123. {{- include "custom_airflow_environment" . | nindent 10 }}
  124. {{- include "standard_airflow_environment" . | nindent 10 }}
  125. {{- end }}
  126. {{- if and (.Values.dags.gitSync.enabled) (not .Values.dags.persistence.enabled) }}
  127. {{- include "git_sync_container" (dict "Values" .Values "is_init" "true") | nindent 8 }}
  128. {{- end }}
  129. {{- if .Values.triggerer.extraInitContainers }}
  130. {{- toYaml .Values.triggerer.extraInitContainers | nindent 8 }}
  131. {{- end }}
  132. containers:
  133. - name: triggerer
  134. image: {{ template "airflow_image" . }}
  135. imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
  136. {{- if .Values.triggerer.command }}
  137. command: {{ tpl (toYaml .Values.triggerer.command) . | nindent 12 }}
  138. {{- end }}
  139. {{- if .Values.triggerer.args }}
  140. args: {{ tpl (toYaml .Values.triggerer.args) . | nindent 12 }}
  141. {{- end }}
  142. resources:
  143. {{ toYaml .Values.triggerer.resources | nindent 12 }}
  144. volumeMounts:
  145. {{- if .Values.triggerer.extraVolumeMounts }}
  146. {{ toYaml .Values.triggerer.extraVolumeMounts | nindent 12 }}
  147. {{- end }}
  148. - name: logs
  149. mountPath: {{ template "airflow_logs" . }}
  150. - name: config
  151. mountPath: {{ template "airflow_config_path" . }}
  152. subPath: airflow.cfg
  153. readOnly: true
  154. {{- if .Values.airflowLocalSettings }}
  155. - name: config
  156. mountPath: {{ template "airflow_local_setting_path" . }}
  157. subPath: airflow_local_settings.py
  158. readOnly: true
  159. {{- end }}
  160. {{- if or .Values.dags.persistence.enabled .Values.dags.gitSync.enabled }}
  161. {{- include "airflow_dags_mount" . | nindent 12 }}
  162. {{- end }}
  163. envFrom:
  164. {{- include "custom_airflow_environment_from" . | default "\n []" | nindent 10 }}
  165. env:
  166. {{- include "custom_airflow_environment" . | nindent 10 }}
  167. {{- include "standard_airflow_environment" . | nindent 10 }}
  168. livenessProbe:
  169. initialDelaySeconds: {{ .Values.triggerer.livenessProbe.initialDelaySeconds }}
  170. timeoutSeconds: {{ .Values.triggerer.livenessProbe.timeoutSeconds }}
  171. failureThreshold: {{ .Values.triggerer.livenessProbe.failureThreshold }}
  172. periodSeconds: {{ .Values.triggerer.livenessProbe.periodSeconds }}
  173. exec:
  174. command:
  175. {{- if .Values.triggerer.livenessProbe.command }}
  176. {{ toYaml .Values.triggerer.livenessProbe.command | nindent 16 }}
  177. {{- else }}
  178. {{- include "triggerer_liveness_check_command" . | nindent 16 }}
  179. {{- end }}
  180. {{- if and (.Values.dags.gitSync.enabled) (not .Values.dags.persistence.enabled) }}
  181. {{- include "git_sync_container" . | indent 8 }}
  182. {{- end }}
  183. {{- if .Values.triggerer.extraContainers }}
  184. {{- toYaml .Values.triggerer.extraContainers | nindent 8 }}
  185. {{- end }}
  186. volumes:
  187. - name: config
  188. configMap:
  189. name: {{ template "airflow_config" . }}
  190. {{- if .Values.dags.persistence.enabled }}
  191. - name: dags
  192. persistentVolumeClaim:
  193. claimName: {{ template "airflow_dags_volume_claim" . }}
  194. {{- else if .Values.dags.gitSync.enabled }}
  195. - name: dags
  196. emptyDir: {}
  197. {{- end }}
  198. {{- if and .Values.dags.gitSync.enabled .Values.dags.gitSync.sshKeySecret }}
  199. {{- include "git_sync_ssh_key_volume" . | indent 8 }}
  200. {{- end }}
  201. {{- if .Values.triggerer.extraVolumes }}
  202. {{- toYaml .Values.triggerer.extraVolumes | nindent 8 }}
  203. {{- end }}
  204. {{- if .Values.logs.persistence.enabled }}
  205. - name: logs
  206. persistentVolumeClaim:
  207. claimName: {{ template "airflow_logs_volume_claim" . }}
  208. {{- else }}
  209. - name: logs
  210. emptyDir: {}
  211. {{- end }}
  212. {{- end }}
  213. {{- end }}