<p>I have a MiniKube that is running and I deploy Airflow via docker-compose this way:</p>
<pre><code>---
version: '3'
x-airflow-common:
  &amp;airflow-common
  # In order to add custom dependencies or upgrade provider packages you can use your extended image.
  # Comment the image line, place your Dockerfile in the directory where you placed the docker-compose.yaml
  # and uncomment the &quot;build&quot; line below, Then run `docker-compose build` to build the images.
  image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.1.3}
  # build: .
  environment:
    &amp;airflow-common-env
    AIRFLOW__CORE__EXECUTOR: KubernetesExecutor
    AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
    AIRFLOW__CORE__FERNET_KEY: ''
    AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
    # AIRFLOW__CORE__LOAD_EXAMPLES: 'true'
    AIRFLOW__API__AUTH_BACKEND: 'airflow.api.auth.backend.basic_auth'
    _PIP_ADDITIONAL_REQUIREMENTS: ${_PIP_ADDITIONAL_REQUIREMENTS:-}
  volumes:
    - ~/.kube:/home/airflow/.kube
    - ./dags/:/opt/airflow/dags
    - ./logs:/opt/airflow/logs
    - ./plugins:/opt/airflow/plugins
  user: &quot;${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-0}&quot;
  depends_on:
    redis:
      condition: service_healthy
    postgres:
      condition: service_healthy

services:
  postgres:
    image: postgres:13
    environment:
      POSTGRES_USER: airflow
      POSTGRES_PASSWORD: airflow
      POSTGRES_DB: airflow
    volumes:
      - postgres-db-volume:/var/lib/postgresql/data
    healthcheck:
      test: [&quot;CMD&quot;, &quot;pg_isready&quot;, &quot;-U&quot;, &quot;airflow&quot;]
      interval: 5s
      retries: 5
    restart: always

  redis:
    image: redis:latest
    ports:
      - 6379:6379
    healthcheck:
      test: [&quot;CMD&quot;, &quot;redis-cli&quot;, &quot;ping&quot;]
      interval: 5s
      timeout: 30s
      retries: 50
    restart: always

  airflow-webserver:
    &lt;&lt;: *airflow-common
    command: webserver
    ports:
      - 8080:8080
    healthcheck:
      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;--fail&quot;, &quot;http://localhost:8080/health&quot;]
      interval: 10s
      timeout: 10s
      retries: 5
    restart: always

  airflow-scheduler:
    &lt;&lt;: *airflow-common
    command: scheduler
    healthcheck:
      test: [&quot;CMD-SHELL&quot;, 'airflow jobs check --job-type SchedulerJob --hostname &quot;$${HOSTNAME}&quot;']
      interval: 10s
      timeout: 10s
      retries: 5
    restart: always


  airflow-init:
    &lt;&lt;: *airflow-common
    entrypoint: /bin/bash
    command:
      - -c
      - |
        function ver() {
          printf &quot;%04d%04d%04d%04d&quot; $${1//./ }
        }
        airflow_version=$$(gosu airflow airflow version)
        airflow_version_comparable=$$(ver $${airflow_version})
        min_airflow_version=2.1.0
        min_airlfow_version_comparable=$$(ver $${min_airflow_version})
        if (( airflow_version_comparable &lt; min_airlfow_version_comparable )); then
          echo -e &quot;\033[1;31mERROR!!!: Too old Airflow version $${airflow_version}!\e[0m&quot;
          echo &quot;The minimum Airflow version supported: $${min_airflow_version}. Only use this or higher!&quot;
          exit 1
        fi
        if [[ -z &quot;${AIRFLOW_UID}&quot; ]]; then
          echo -e &quot;\033[1;31mERROR!!!: AIRFLOW_UID not set!\e[0m&quot;
          echo &quot;Please follow these instructions to set AIRFLOW_UID and AIRFLOW_GID environment variables:
            https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#initializing-environment&quot;
          exit 1
        fi
        one_meg=1048576
        mem_available=$$(($$(getconf _PHYS_PAGES) * $$(getconf PAGE_SIZE) / one_meg))
        cpus_available=$$(grep -cE 'cpu[0-9]+' /proc/stat)
        disk_available=$$(df / | tail -1 | awk '{print $$4}')
        warning_resources=&quot;false&quot;
        if (( mem_available &lt; 4000 )) ; then
          echo -e &quot;\033[1;33mWARNING!!!: Not enough memory available for Docker.\e[0m&quot;
          echo &quot;At least 4GB of memory required. You have $$(numfmt --to iec $$((mem_available * one_meg)))&quot;
          warning_resources=&quot;true&quot;
        fi
        if (( cpus_available &lt; 2 )); then
          echo -e &quot;\033[1;33mWARNING!!!: Not enough CPUS available for Docker.\e[0m&quot;
          echo &quot;At least 2 CPUs recommended. You have $${cpus_available}&quot;
          warning_resources=&quot;true&quot;
        fi
        if (( disk_available &lt; one_meg * 10 )); then
          echo -e &quot;\033[1;33mWARNING!!!: Not enough Disk space available for Docker.\e[0m&quot;
          echo &quot;At least 10 GBs recommended. You have $$(numfmt --to iec $$((disk_available * 1024 )))&quot;
          warning_resources=&quot;true&quot;
        fi
        if [[ $${warning_resources} == &quot;true&quot; ]]; then
          echo
          echo -e &quot;\033[1;33mWARNING!!!: You have not enough resources to run Airflow (see above)!\e[0m&quot;
          echo &quot;Please follow the instructions to increase amount of resources available:&quot;
          echo &quot;   https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#before-you-begin&quot;
        fi
        mkdir -p /sources/logs /sources/dags /sources/plugins
        chown -R &quot;${AIRFLOW_UID}:${AIRFLOW_GID}&quot; /sources/{logs,dags,plugins}
        exec /entrypoint airflow version
    environment:
      &lt;&lt;: *airflow-common-env
      _AIRFLOW_DB_UPGRADE: 'true'
      _AIRFLOW_WWW_USER_CREATE: 'true'
      _AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow}
      _AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}
    user: &quot;0:${AIRFLOW_GID:-0}&quot;
    volumes:
      - .:/sources

volumes:
  postgres-db-volume:
</code></pre>
<p>But the connection between Airflow and Kubernetes seems to fail (removing the AIRFLOW__CORE__EXECUTOR varenv allows the creation):</p>
<pre><code>airflow-scheduler_1  | Traceback (most recent call last):
airflow-scheduler_1  |   File &quot;/home/airflow/.local/bin/airflow&quot;, line 8, in &lt;module&gt;
airflow-scheduler_1  |     sys.exit(main())
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py&quot;, line 40, in main
airflow-scheduler_1  |     args.func(args)
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_parser.py&quot;, line 48, in command
airflow-scheduler_1  |     return func(*args, **kwargs)
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/cli.py&quot;, line 91, in wrapper
airflow-scheduler_1  |     return f(*args, **kwargs)
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/scheduler_command.py&quot;, line 70, in scheduler
airflow-scheduler_1  |     job.run()
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/base_job.py&quot;, line 245, in run
airflow-scheduler_1  |     self._execute()
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py&quot;, line 686, in _execute
airflow-scheduler_1  |     self.executor.start()
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/executors/kubernetes_executor.py&quot;, line 485, in start
airflow-scheduler_1  |     self.kube_client = get_kube_client()
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/kubernetes/kube_client.py&quot;, line 145, in get_kube_client
airflow-scheduler_1  |     client_conf = _get_kube_config(in_cluster, cluster_context, config_file)
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/airflow/kubernetes/kube_client.py&quot;, line 40, in _get_kube_config
airflow-scheduler_1  |     config.load_incluster_config()
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/kubernetes/config/incluster_config.py&quot;, line 93, in load_incluster_config
airflow-scheduler_1  |     InClusterConfigLoader(token_filename=SERVICE_TOKEN_FILENAME,
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/kubernetes/config/incluster_config.py&quot;, line 45, in load_and_set
airflow-scheduler_1  |     self._load_config()
airflow-scheduler_1  |   File &quot;/home/airflow/.local/lib/python3.8/site-packages/kubernetes/config/incluster_config.py&quot;, line 51, in _load_config
airflow-scheduler_1  |     raise ConfigException(&quot;Service host/port is not set.&quot;)
airflow-scheduler_1  | kubernetes.config.config_exception.ConfigException: Service host/port is not set.
</code></pre>
<p>My Idea is that the kube config file is not correctly found by the Airflow Scheduler. I mounted the volume <code>~/.kube:/home/airflow/.kube</code> but can't find a way to make it work.</p>

val
<p>Using Docker Compose to run KubernetesExecutor seems like a bad idea.</p>
<p>Why would you want to do it?</p>
<p>It makes a lot more sense to use the official Helm Chart - it's easier to manage and configure, you can easily deploy it to your minikube and it will work out-of-the-box with KubernetesExecutor.</p>
<p><a href="https://airflow.apache.org/docs/helm-chart/stable/index.html" rel="nofollow noreferrer">https://airflow.apache.org/docs/helm-chart/stable/index.html</a></p>
