apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
  namespace: airflow
spec:
  selector:
    matchLabels:
      app: web
  serviceName: web
  template:
    metadata:
      labels:
        app: web
    spec:
      initContainers:
        - name: init
          image: watchdg/airflow:1
          imagePullPolicy: Always
          args:
            - initdb
          envFrom:
            - secretRef:
                name: airflow
      containers:
        - name: repo
          image: watchdg/repo
          imagePullPolicy: Always
          workingDir: /opt/airflow/dags
          command:
            - sh
            - -c
            - git clone $(GIT_REPO) . && watch -n 300 git pull
          env:
            - name: GIT_REPO
              valueFrom:
                secretKeyRef:
                  name: airflow
                  key: GIT_REPO
          volumeMounts:
            - name: dags
              mountPath: /opt/airflow/dags
        - name: web
          image: watchdg/airflow:1
          imagePullPolicy: Always
          args:
            - webserver
          envFrom:
            - secretRef:
                name: airflow
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: dags
              mountPath: /opt/airflow/dags
      volumes:
        - name: dags
          emptyDir: {}