apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    chart: airflow-1.4.0
    component: triggerer
    heritage: Helm
    release: RELEASE-NAME
    tier: airflow
  name: RELEASE-NAME-triggerer
spec:
  replicas: 1
  selector:
    matchLabels:
      component: triggerer
      release: RELEASE-NAME
      tier: airflow
  strategy:
    rollingUpdate:
      maxSurge: 100%
      maxUnavailable: 50%
  template:
    metadata:
      annotations:
        checksum/airflow-config: 708936888fa3858db029c48b74c491386b92b6f1b4a6c41ae7476b17dc274f10
        checksum/extra-configmaps: 2e44e493035e2f6a255d08f8104087ff10d30aef6f63176f1b18f75f73295598
        checksum/extra-secrets: bb91ef06ddc31c0c5a29973832163d8b0b597812a793ef911d33b622bc9d1655
        checksum/metadata-secret: 7c54201013e432b164782aa58433e49a9cd14d0581827b7964e495ccdbd010db
        checksum/pgbouncer-config-secret: da52bd1edfe820f0ddfacdebb20a4cc6407d296ee45bcb500a6407e2261a5ba2
        cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
      labels:
        component: triggerer
        release: RELEASE-NAME
        tier: airflow
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  component: triggerer
              topologyKey: kubernetes.io/hostname
            weight: 100
      containers:
      - args:
        - bash
        - -c
        - exec airflow triggerer
        env:
        - name: AIRFLOW__CORE__FERNET_KEY
          valueFrom:
            secretKeyRef:
              key: fernet-key
              name: RELEASE-NAME-fernet-key
        - name: AIRFLOW__CORE__SQL_ALCHEMY_CONN
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-metadata
        - name: AIRFLOW_CONN_AIRFLOW_DB
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-metadata
        - name: AIRFLOW__WEBSERVER__SECRET_KEY
          valueFrom:
            secretKeyRef:
              key: webserver-secret-key
              name: RELEASE-NAME-webserver-secret-key
        - name: AIRFLOW__CELERY__CELERY_RESULT_BACKEND
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-result-backend
        - name: AIRFLOW__CELERY__RESULT_BACKEND
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-result-backend
        - name: AIRFLOW__CELERY__BROKER_URL
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-broker-url
        envFrom: []
        image: apache/airflow:2.2.3
        imagePullPolicy: IfNotPresent
        livenessProbe:
          exec:
            command:
            - /entrypoint
            - python
            - -Wignore
            - -c
            - |
              import os
              os.environ['AIRFLOW__CORE__LOGGING_LEVEL'] = 'ERROR'
              os.environ['AIRFLOW__LOGGING__LOGGING_LEVEL'] = 'ERROR'

              from airflow.jobs.triggerer_job import TriggererJob
              from airflow.utils.db import create_session
              from airflow.utils.net import get_hostname
              import sys

              with create_session() as session:
                  job = session.query(TriggererJob).filter_by(hostname=get_hostname()).order_by(
                      TriggererJob.latest_heartbeat.desc()).limit(1).first()

              sys.exit(0 if job.is_alive() else 1)
          failureThreshold: 5
          initialDelaySeconds: 10
          periodSeconds: 60
          timeoutSeconds: 20
        name: triggerer
        resources: {}
        volumeMounts:
        - mountPath: /opt/airflow/logs
          name: logs
        - mountPath: /opt/airflow/airflow.cfg
          name: config
          readOnly: true
          subPath: airflow.cfg
        - mountPath: /opt/airflow/config/airflow_local_settings.py
          name: config
          readOnly: true
          subPath: airflow_local_settings.py
      initContainers:
      - args:
        - airflow
        - db
        - check-migrations
        - --migration-wait-timeout=60
        env:
        - name: AIRFLOW__CORE__FERNET_KEY
          valueFrom:
            secretKeyRef:
              key: fernet-key
              name: RELEASE-NAME-fernet-key
        - name: AIRFLOW__CORE__SQL_ALCHEMY_CONN
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-metadata
        - name: AIRFLOW_CONN_AIRFLOW_DB
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-metadata
        - name: AIRFLOW__WEBSERVER__SECRET_KEY
          valueFrom:
            secretKeyRef:
              key: webserver-secret-key
              name: RELEASE-NAME-webserver-secret-key
        - name: AIRFLOW__CELERY__CELERY_RESULT_BACKEND
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-result-backend
        - name: AIRFLOW__CELERY__RESULT_BACKEND
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-airflow-result-backend
        - name: AIRFLOW__CELERY__BROKER_URL
          valueFrom:
            secretKeyRef:
              key: connection
              name: RELEASE-NAME-broker-url
        envFrom: []
        image: apache/airflow:2.2.3
        imagePullPolicy: IfNotPresent
        name: wait-for-airflow-migrations
        resources: {}
      nodeSelector: {}
      restartPolicy: Always
      securityContext:
        fsGroup: 0
        runAsUser: 50000
      serviceAccountName: RELEASE-NAME-airflow-triggerer
      terminationGracePeriodSeconds: 60
      tolerations: []
      volumes:
      - configMap:
          name: RELEASE-NAME-airflow-config
        name: config
      - emptyDir: {}
        name: logs
