how to set a default image while using KubernetesExecutor in airflow

10/5/2021
  1. I'm using KubernetesExecutor.
  2. config
    AIRFLOW__KUBERNETES__IN_CLUSTER: 'false'
    AIRFLOW__KUBERNETES__CONFIG_FILE: ~/.kube/config
    AIRFLOW__KUBERNETES__NAMESPACE: airflow
    AIRFLOW__KUBERNETES__POD_TEMPLATE_FILE: /home/airflow/pod_template.yaml
  1. pod_template_file
apiVersion: v1
kind: Pod
metadata:
  name: dummy-name
spec:
  initContainers:
    - name: git-sync
      image: "[repo]/git-sync:v3.1.6"
      env:
        - name: GIT_SYNC_REPO
          value: ""
        - name: GIT_SYNC_ROOT
          value: "/tmp/git"
        - name: GIT_SYNC_DEPTH
          value: "1"
        - name: GIT_SYNC_WAIT
          value: "60"
        - name: GIT_SYNC_USERNAME
          value: [username]
        - name: GIT_SYNC_PASSWORD
          value: [password]
      volumeMounts:
        - name: airflow-dags
          mountPath: /tmp/git
  containers:
    - args: []
      command: []
      env:
        - name: AIRFLOW__CORE__EXECUTOR
          value: LocalExecutor
        - name: AIRFLOW__CORE__SQL_ALCHEMY_CONN
          value: [conn str]
        - name: AIRFLOW__CORE__DAGS_FOLDER
          value: [dag folder]
      envFrom: []
      image: "[repo]/airflow:2.1.3"
      imagePullPolicy: IfNotPresent
      name: base
      ports: []
      volumeMounts:
        - mountPath: "/opt/airflow/logs"
          name: airflow-logs
        - mountPath: /opt/airflow/dags
          name: airflow-dags
          readOnly: false
  hostNetwork: false
  restartPolicy: Never
  securityContext:
    runAsUser: 50000
    fsGroup: 50000
  nodeSelector:
    {}
  affinity:
    {}
  tolerations:
    []
  volumes:
    - name: airflow-dags
      emptyDir: {}
    - emptyDir: {}
      name: airflow-logs
    - configMap:
        name: RELEASE-NAME-airflow-config
      name: airflow-config
    - configMap:
        name: RELEASE-NAME-airflow-config
      name: airflow-local-settings
  1. When I ran a dag, I got this in Kubernetes. Other settings was fine. Only image setting was not worked.
    enter image description here

If I specify a image of a dag's operator with pod_override, it works. But that is not what I want. I want to set a default image by config. How could I do that?

(Stackoverflow wants more words...blahblah... bl...ah... blah....)

-- JEONGHYEON OH
airflow
kubernetes
kubernetesexecutor

0 Answers