{{- if .Values.workers.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "airflow.fullname" . }}-flower
  labels:
    app: {{ template "airflow.name" . }}
    component: flower
    chart: {{ template "airflow.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: 1
  minReadySeconds: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app: {{ template "airflow.name" . }}
      component: flower
      release: {{ .Release.Name }}
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap-airflow.yaml") . | sha256sum }}
        configmap.fabric8.io/update-on-change: "{{ template "airflow.fullname" . }}-env"
      labels:
        app: {{ template "airflow.name" . }}
        component: flower
        release: {{ .Release.Name }}
    spec:
      {{- if .Values.airflow.image.pullSecret }}
      imagePullSecrets:
        - name: {{ .Values.airflow.image.pullSecret }}
      {{- end }}
      restartPolicy: Always
      containers:
        - name: {{ .Chart.Name }}-flower
          image: {{ .Values.airflow.image.repository }}:{{ .Values.airflow.image.tag }}
          imagePullPolicy: {{ .Values.airflow.image.pullPolicy }}
          envFrom:
            - configMapRef:
                name: "{{ template "airflow.fullname" . }}-env"
          env:
          {{- include "airflow.mapenvsecrets" . | indent 10 }}
          ports:
            - name: flower
              containerPort: 5555
              protocol: TCP
          args: ["flower"]
          livenessProbe:
            httpGet:
              path: "{{ .Values.ingress.flower.livenessPath }}/"
              port: flower
            initialDelaySeconds: 60
            periodSeconds: 60
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 5
{{- end }}
