apiVersion: v1
kind: ConfigMap
metadata:
  name: airflow-worker-pod-template
  namespace: airflow
data:
  worker-pod-template.yml: |
    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: worker-pod
      namespace: airflow
    spec:
      automountServiceAccountToken: true
      serviceAccountName: airflow
      restartPolicy: Never
      initContainers:
      - name: s3-pull
        image: amazonlinux:latest
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh", "-c"]
        args: ["yum install awscli -y && aws s3 sync s3://${AWS_S3_DAGS_BUCKET} /mnt --delete"]
        envFrom:
        - configMapRef:
            name: airflow-config
        env:
        - name: AWS_S3_DAGS_BUCKET
          value: "tht-airflow-dags"
        - name: AWS_S3_LOGS_BUCKET
          value: "tht-airflow-logs"
        volumeMounts:
        - name: dags-folder
          mountPath: /mnt
      containers:
      - name: base
        image: dummy-image
        imagePullPolicy: Always
        command: []
        args: []
        env:
        - name: AIRFLOW__CORE__EXECUTOR
          value: "LocalExecutor"
        envFrom:
        - configMapRef:
            name: airflow-config
        env:
        - name: AWS_S3_DAGS_BUCKET
          value: "tht-airflow-dags"
        - name: AWS_S3_LOGS_BUCKET
          value: "tht-airflow-logs"
        resources:
          requests:
            cpu: "100m"
            memory: "128Mi"
          limits:
            cpu: "200m"
            memory: "256Mi"
        volumeMounts:
        - name: dags-folder
          mountPath: /opt/airflow/dags
      volumes:
      - name: dags-folder
        emptyDir: {}
