---
# Source: airflow/templates/deployments-scheduler.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: airflow-scheduler
  labels:
    app: airflow
    component: scheduler
    chart: airflow-5.2.0
    release: airflow
    heritage: Tiller
spec:
  replicas: 1
  strategy:
    # Kill the scheduler as soon as possible. It will restart quickly with all the workers,
    # minimizing the time they are not synchronized.
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 100%
  selector:
    matchLabels:
      app: airflow
      component: scheduler
      release: airflow
  template:
    metadata:
      annotations:
        checksum/config-env: 4ee020624b4c4e6c7e5b7a1e9161839eaeb06c462968cd4c3e1066cdef5eaeca
        checksum/config-git-clone: f1ccca4494c87cfd3b6a582326f8b995ffb3c65bf4ed4341c188de9e98dd9ae5
        checksum/config-scripts: c286309579b6482ec7922f5bf3d1c509aecd617e8ea9c9a305af610658a21dc0
        checksum/config-variables-pools: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
        checksum/secret-connections: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
      labels:
        app: airflow
        component: scheduler
        release: airflow
    spec:
      restartPolicy: Always
      serviceAccountName: airflow
      containers:
        - name: airflow-scheduler
          image: puckel/docker-airflow:1.10.4
          imagePullPolicy: IfNotPresent
          envFrom:
          - configMapRef:
              name: "airflow-env"
          env:          
            - name: POSTGRES_USER
              value: "postgres"
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: airflow-postgresql
                  key: postgres-password
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: airflow-redis
                  key: redis-password
          resources:
            {}
            
          volumeMounts:
            - name: scripts
              mountPath: /usr/local/scripts
          args:
            - "bash"
            - "-c"
            - >
              echo 'waiting 10s...' &&
              sleep 10 &&
              mkdir -p /usr/local/airflow/.local/bin &&
              export PATH=/usr/local/airflow/.local/bin:$PATH &&
              echo "executing initdb" &&
              airflow initdb &&
              echo "executing scheduler" &&
              airflow scheduler -n -1
      volumes:
        - name: scripts
          configMap:
            name: airflow-scripts
            defaultMode: 0755
        - name: dags-data
          emptyDir: {}
