title: Airflow + Kubernetes worker database connection
body: <p>I've managed to set up an Airflow deployment in Kubernetes (webserver and scheduler) configured with Kubernetes Executor and a Postgres schema with Airflow metadata.</p>
  <p>I'm trying to make the <code>example_bash_operator</code> DAG working but the worker pod keeps failing because of the following SQLAlchemy exception:</p>
  <blockquote>
  <p>2021-01-07 10:29:33,091] {cli_action_loggers.py:105} WARNING - Failed
  to log action with (sqlite3.OperationalError) no such table: log [SQL:
  INSERT INTO log (dttm, dag_id, task_id, event, execution_date, owner,
  extra) VALUES (?, ?, ?, ?, ?, ?, ?)] [parameters: ('2021-01-07
  10:29:33.082018', 'example_bash_operator', 'runme_0', 'cli_task_run',
  '2021-01-07 09:11:29.947161', 'airflow', '{&quot;host_name&quot;:
  &quot;examplebashoperatorrunme0-495d985192ab4269a3dce023851a34b7&quot;,
  &quot;full_command&quot;: &quot;['/usr/local/bin/airflow', 'tasks', 'run',
  'examp ... (70 characters truncated) ...  '--local', '--pool',
  'default_pool', '--subdir',
  '/usr/local/lib/python3.8/site-packages/airflow/example_dags/example_bash_operator.py']&quot;}')]
  (Background on this error at: <a href="http://sqlalche.me/e/13/e3q8" rel="nofollow noreferrer">http://sqlalche.me/e/13/e3q8</a>)
  [2021-01-07 10:29:33,097] {dagbag.py:440} INFO - Filling up the DagBag
  from
  /usr/local/lib/python3.8/site-packages/airflow/example_dags/example_bash_operator.py
  [2021-01-07 10:29:33,197] {dagbag.py:297} ERROR - Failed to import:
  /usr/local/lib/python3.8/site-packages/airflow/example_dags/example_subdag_operator.py
  Traceback (most recent call last):   File
  &quot;/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py&quot;,
  line 1276, in _execute_context
  self.dialect.do_execute(   File &quot;/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py&quot;,
  line 609, in do_execute
  cursor.execute(statement, parameters) sqlite3.OperationalError: no such table: slot_pool</p>
  </blockquote>
  <p>To my understanding, the worker pod is trying to fetch metadata from the sqlite db, but the database doesn't hold any of these tables. I already have a database for metadata and I'd like the workers to use the Postgres metadata database I set up as the default one.</p>
  <p>A worker container image is the following:</p>
  <pre><code>FROM python:3.8.7-slim
  
  ARG AIRFLOW_USER_HOME=/var/lib/airflow
  ARG AIRFLOW_USER=&quot;airflow&quot;
  ARG AIRFLOW_UID=&quot;1000&quot;
  ARG AIRFLOW_GID=&quot;100&quot;
  ENV AIRFLOW_HOME=$AIRFLOW_USER_HOME
  ENV AIRFLOW__CORE__SQL_ALCHEMY_CONN=&quot;postgresql://user:pass@databaseip:5432/airflow_metadata&quot;
  RUN mkdir $AIRFLOW_USER_HOME &amp;&amp; \
    useradd -ms /bin/bash -u $AIRFLOW_UID airflow &amp;&amp; \
    chown $AIRFLOW_USER:$AIRFLOW_GID $AIRFLOW_USER_HOME &amp;&amp; \
    buildDeps='freetds-dev libkrb5-dev libsasl2-dev libssl-dev libffi-dev libpq-dev' \
    apt-get update &amp;&amp; \
    apt-get install -yqq --no-install-recommends $buildDeps build-essential default-libmysqlclient-dev &amp;&amp; \
    pip install --no-cache-dir 'apache-airflow[crypto,kubernetes,postgres]' &amp;&amp; \
    apt-get purge --auto-remove -yqq $buildDeps &amp;&amp; \
    apt-get autoremove -yqq --purge &amp;&amp; \
    rm -rf /var/lib/apt/lists/*
  
  USER $AIRFLOW_UID
  
  WORKDIR $AIRFLOW_USER_HOME
  </code></pre>
  <p>It's clear I'm missing something very obvious in how airflow manages its worker.
  Can anybody please explain to me how Airflow manages this?</p>