flower-deployment.yaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 Flower Deployment
  19. #################################
  20. {{- if .Values.flower.enabled }}
  21. {{- if or (eq .Values.executor "CeleryExecutor") (eq .Values.executor "CeleryKubernetesExecutor") }}
  22. {{- $nodeSelector := or .Values.flower.nodeSelector .Values.nodeSelector }}
  23. {{- $affinity := or .Values.flower.affinity .Values.affinity }}
  24. {{- $tolerations := or .Values.flower.tolerations .Values.tolerations }}
  25. {{- $topologySpreadConstraints := or .Values.flower.topologySpreadConstraints .Values.topologySpreadConstraints }}
  26. {{- $securityContext := include "airflowSecurityContext" (list . .Values.flower) }}
  27. kind: Deployment
  28. apiVersion: apps/v1
  29. metadata:
  30. name: {{ .Release.Name }}-flower
  31. labels:
  32. tier: airflow
  33. component: flower
  34. release: {{ .Release.Name }}
  35. chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  36. heritage: {{ .Release.Service }}
  37. {{- with .Values.labels }}
  38. {{ toYaml . | indent 4 }}
  39. {{- end }}
  40. spec:
  41. replicas: 1
  42. selector:
  43. matchLabels:
  44. tier: airflow
  45. component: flower
  46. release: {{ .Release.Name }}
  47. template:
  48. metadata:
  49. labels:
  50. tier: airflow
  51. component: flower
  52. release: {{ .Release.Name }}
  53. {{- with .Values.labels }}
  54. {{ toYaml . | indent 8 }}
  55. {{- end }}
  56. annotations:
  57. checksum/airflow-config: {{ include (print $.Template.BasePath "/configmaps/configmap.yaml") . | sha256sum }}
  58. checksum/flower-secret: {{ include (print $.Template.BasePath "/secrets/flower-secret.yaml") . | sha256sum }}
  59. {{- if or (.Values.airflowPodAnnotations) (.Values.flower.podAnnotations) }}
  60. {{- mustMerge .Values.flower.podAnnotations .Values.airflowPodAnnotations | toYaml | nindent 8 }}
  61. {{- end }}
  62. spec:
  63. nodeSelector:
  64. {{ toYaml $nodeSelector | indent 8 }}
  65. affinity:
  66. {{ toYaml $affinity | indent 8 }}
  67. tolerations:
  68. {{ toYaml $tolerations | indent 8 }}
  69. topologySpreadConstraints:
  70. {{ toYaml $topologySpreadConstraints | indent 8 }}
  71. serviceAccountName: {{ include "flower.serviceAccountName" . }}
  72. {{- if .Values.flower.priorityClassName }}
  73. priorityClassName: {{ .Values.flower.priorityClassName }}
  74. {{- end }}
  75. restartPolicy: Always
  76. securityContext: {{ $securityContext | nindent 8 }}
  77. {{- if or .Values.registry.secretName .Values.registry.connection }}
  78. imagePullSecrets:
  79. - name: {{ template "registry_secret" . }}
  80. {{- end }}
  81. containers:
  82. - name: flower
  83. image: {{ template "flower_image" . }}
  84. imagePullPolicy: {{ .Values.images.flower.pullPolicy }}
  85. {{- if .Values.flower.command }}
  86. command: {{ tpl (toYaml .Values.flower.command) . | nindent 12 }}
  87. {{- end }}
  88. {{- if .Values.flower.args }}
  89. args: {{ tpl (toYaml .Values.flower.args) . | nindent 12 }}
  90. {{- end }}
  91. resources:
  92. {{ toYaml .Values.flower.resources | indent 12 }}
  93. volumeMounts:
  94. - name: config
  95. mountPath: {{ template "airflow_config_path" . }}
  96. subPath: airflow.cfg
  97. readOnly: true
  98. {{- if .Values.flower.extraVolumeMounts }}
  99. {{ toYaml .Values.flower.extraVolumeMounts | nindent 12 }}
  100. {{- end }}
  101. ports:
  102. - name: flower-ui
  103. containerPort: {{ .Values.ports.flowerUI }}
  104. livenessProbe:
  105. failureThreshold: 10
  106. exec:
  107. command:
  108. - curl
  109. {{- if (or .Values.flower.secretName (and .Values.flower.username .Values.flower.password))}}
  110. - "--user"
  111. - $AIRFLOW__CELERY__FLOWER_BASIC_AUTH
  112. {{- end }}
  113. - {{ printf "localhost:%s" (.Values.ports.flowerUI | toString) }}
  114. initialDelaySeconds: 10
  115. periodSeconds: 5
  116. readinessProbe:
  117. failureThreshold: 10
  118. exec:
  119. command:
  120. - curl
  121. {{- if (or .Values.flower.secretName (and .Values.flower.username .Values.flower.password))}}
  122. - "--user"
  123. - $AIRFLOW__CELERY__FLOWER_BASIC_AUTH
  124. {{- end }}
  125. - {{ printf "localhost:%s" (.Values.ports.flowerUI | toString) }}
  126. initialDelaySeconds: 10
  127. periodSeconds: 5
  128. envFrom:
  129. {{- include "custom_airflow_environment_from" . | default "\n []" | indent 10 }}
  130. env:
  131. {{- if (or .Values.flower.secretName (and .Values.flower.username .Values.flower.password))}}
  132. - name: AIRFLOW__CELERY__FLOWER_BASIC_AUTH
  133. valueFrom:
  134. secretKeyRef:
  135. name: {{ template "flower_secret" . }}
  136. key: basicAuth
  137. {{- end }}
  138. {{- include "standard_airflow_environment" . | indent 10 }}
  139. {{- include "custom_airflow_environment" . | indent 10 }}
  140. {{- if .Values.flower.extraContainers }}
  141. {{- toYaml .Values.flower.extraContainers | nindent 8 }}
  142. {{- end }}
  143. volumes:
  144. - name: config
  145. configMap:
  146. name: {{ template "airflow_config" . }}
  147. {{- if .Values.flower.extraVolumes }}
  148. {{ toYaml .Values.flower.extraVolumes | indent 8 }}
  149. {{- end }}
  150. {{- end }}
  151. {{- end }}