<pre class="lang-sh prettyprint-override"><code>➜ k get pods -n edna    
NAME                              READY   STATUS    RESTARTS   AGE
airflow-79d5f59644-dd4k7          1/1     Running   0          16h
airflow-worker-67bcf7844b-rq7r8   1/1     Running   0          22h
backend-65bcb6546-wvvqj           1/1     Running   0          2d16h

</code></pre>
<p>so airflow running in <strong>airflow-79d5f59644-dd4k7</strong> pod is trying to get logs extracted from the airflow worker (celery/python, which runs a simple flask based webserver handling logs) and it can't because domain name <strong>airflow-worker-67bcf7844b-rq7r8</strong> is not resolved inside <strong>airflow-79d5f59644-dd4k7</strong></p>
<pre><code>*** Log file does not exist: /usr/local/airflow/logs/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log
*** Fetching from: http://airflow-worker-67bcf7844b-rq7r8:8793/log/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log
*** Failed to fetch log file from worker. HTTPConnectionPool(host='airflow-worker-67bcf7844b-rq7r8', port=8793): Max retries exceeded with url: /log/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7fd37d6a9790&gt;: Failed to establish a new connection: [Errno -2] Name or service not known'))

</code></pre>
<p>How can I make this work?</p>
<p>I understand that Airflow has remote logging to s3, but Is there a way to route requests by POD random hasotnames?</p>
<p>I have created a NodeType Service, but airflow has NO idea about DNS name for that service and is trying to access logs by hostname of the airflow worker (reported back by Celery).</p>
<pre><code>➜ k get pods -n edna
NAME                              READY   STATUS    RESTARTS   AGE
airflow-79d5f59644-dd4k7          1/1     Running   0          16h
airflow-worker-67bcf7844b-rq7r8   1/1     Running   0          22h
backend-65bcb6546-wvvqj           1/1     Running   0          2d17h

kubectl get pods -n edna -l app=edna-airflow-worker \                                                                        
    -o go-template='{{range .items}}{{.status.podIP}}{{&quot;\n&quot;}}{{end}}'
'Tipz:' kgp -n edna -l app=edna-airflow-worker \ -o go-template='{{range .items}}{{.status.podIP}}{{&quot; &quot;}}{{end}}'
10.0.101.120
</code></pre>
<p>Get inside the <strong>airflow-79d5f59644-dd4k7</strong> pod</p>
<pre><code>k exec -ti -n edna airflow-79d5f59644-dd4k7 bash  

🐳  [DEV] airflow-79d5f59644-dd4k7 app # curl -L http://airflow-worker-67bcf7844b-rq7r8:8793/log/hello_world/hello_task/2020-07-14T21:59:01.400678+00:00/1.log

curl: (6) Could not resolve host: airflow-worker-67bcf7844b-rq7r8; Unknown error
🐳  [DEV] airflow-79d5f59644-dd4k7 app # curl -L http://10.0.101.120:8793/log/hello_world/hello_task/2020-07-14T21:59:01.400678+00:00/1.log
[2020-07-14 21:59:07,257] {{taskinstance.py:669}} INFO - Dependencies all met for &lt;TaskInstance: hello_world.hello_task 2020-07-14T21:59:01.400678+00:00 [queued]&gt;
[2020-07-14 21:59:07,341] {{taskinstance.py:669}} INFO - Dependencies all met for &lt;TaskInstance: hello_world.hello_task 2020-07-14T21:59:01.400678+00:00 [queued]&gt;
[2020-07-14 21:59:07,342] {{taskinstance.py:879}} INFO - 
--------------------------------------------------------------------------------
[2020-07-14 21:59:07,342] {{taskinstance.py:880}} INFO - Starting attempt 1 of 1
[2020-07-14 21:59:07,342] {{taskinstance.py:881}} INFO - 
--------------------------------------------------------------------------------
[2020-07-14 21:59:07,348] {{taskinstance.py:900}} INFO - Executing &lt;Task(PythonOperator): hello_task&gt; on 2020-07-14T21:59:01.400678+00:00
[2020-07-14 21:59:07,351] {{standard_task_runner.py:53}} INFO - Started process 5795 to run task
[2020-07-14 21:59:07,912] {{logging_mixin.py:112}} INFO - Running %s on host %s &lt;TaskInstance: hello_world.hello_task 2020-07-14T21:59:01.400678+00:00 [running]&gt; airflow-worker-67bcf7844b-rq7r8
[2020-07-14 21:59:07,989] {{logging_mixin.py:112}} INFO - Hello world! This is really cool!
[2020-07-14 21:59:07,989] {{python_operator.py:114}} INFO - Done. Returned value was: Hello world! This is really cool!
[2020-07-14 21:59:08,161] {{taskinstance.py:1065}} INFO - Marking task as SUCCESS.dag_id=hello_world, task_id=hello_task, execution_date=20200714T215901, start_date=20200714T215907, end_date=20200714T215908
[2020-07-14 21:59:17,070] {{logging_mixin.py:112}} INFO - [2020-07-14 21:59:17,070] {{local_task_job.py:103}} INFO - Task exited with return code 0
🐳  [DEV] airflow-79d5f59644-dd4k7 app # 


</code></pre>

<p><strong>Solution</strong></p>
<p>Provide the following ENV <strong>AIRFLOW__CORE__HOSTNAME_CALLABLE</strong> for the deployment.yaml of the worker pod:</p>
<pre><code>env:
  - name: AIRFLOW__CORE__HOSTNAME_CALLABLE
    value: 'airflow.utils.net:get_host_ip_address'
</code></pre>
<p>Or just change airflow.cfg</p>
<p>then airflow is trying to access by IP of the POD and things are working if your POD exposes port <strong>8793</strong></p>
