<p>I have deployed apache airflow in azure kubernetes.</p>
<p>Helm repository of apache airflow: <a href="https://github.com/apache/airflow/tree/master/chart" rel="nofollow noreferrer">https://github.com/apache/airflow/tree/master/chart</a></p>
<p>AKS version: 1.16.13</p>
<p>Once I have airflow deployed I have tested it with this dag:</p>
<pre class="lang-py prettyprint-override"><code>from airflow import DAG
from datetime import datetime, timedelta
from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
from airflow.operators.dummy_operator import DummyOperator


default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime.utcnow(),
    'email': ['airflow@example.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5)
}

dag = DAG(
    'kubernetes_sample', default_args=default_args, schedule_interval=timedelta(minutes=10))


start = DummyOperator(task_id='run_this_first', dag=dag)

passing = KubernetesPodOperator(namespace='default',
                          image=&quot;python:3.8-slim-buster&quot;,
                          cmds=[&quot;python3&quot;,&quot;-c&quot;],
                          arguments=[&quot;print('hello world')&quot;],
                          labels={&quot;foo&quot;: &quot;bar&quot;},
                          name=&quot;passing-test&quot;,
                          task_id=&quot;passing-task&quot;,
                          get_logs=True,
                          dag=dag
                          )


passing.set_upstream(start)
</code></pre>
<p>It works fine. Now I want to use my own images. For that, I am using azure containers, and following this  guide: <a href="https://airflow.readthedocs.io/en/latest/howto/operator/kubernetes.html" rel="nofollow noreferrer">https://airflow.readthedocs.io/en/latest/howto/operator/kubernetes.html</a>, I am using this code to create the secret to access to my azure registry:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl create secret docker-registry testquay \
    --docker-server=quay.io \
    --docker-username=&lt;Profile name&gt; \
    --docker-password=&lt;password&gt;
</code></pre>
<p>I build my image and I test locally and it is working. I upload the image to azure container registry and I write the following dag:</p>
<pre class="lang-py prettyprint-override"><code>from airflow import DAG
from datetime import datetime, timedelta
from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
from airflow.operators.dummy_operator import DummyOperator
from airflow.contrib.kubernetes import secret
import logging
import os
import sys
import traceback 

try:
    env_var_secret = secret.Secret(
        deploy_type='env',
        deploy_target='VERSION_NUMBER',
        secret='myregistrykey',
        key='VERSION_NUMBER',
            )
    default_args = {
        'owner': 'airflow',
        'depends_on_past': False,
        'start_date': datetime.utcnow(),
        'email': ['airflow@example.com'],
        'email_on_failure': False,
        'email_on_retry': False,
        'retries': 1,
        'retry_delay': timedelta(minutes=5)
    }

    dag = DAG(
        'jordi_test_get_secert2', default_args=default_args, schedule_interval=timedelta(minutes=10))


    start = DummyOperator(task_id='run_this_first', dag=dag)

    quay_k8s = KubernetesPodOperator(
            namespace='default',
            name=&quot;passing-test7&quot;,
            image='docker.io/test-pai-1',
            image_pull_secrets=env_var_secret,
            task_id=&quot;passing-task6&quot;,
            get_logs=True,
            dag=dag
        )


    start &gt;&gt; quay_k8s

except Exception as e:

    error_message = {
            &quot;message&quot;: &quot;An internal error ocurred&quot;
            ,&quot;error&quot;: str(e)
            , &quot;error information&quot; : str(sys.exc_info())
            , &quot;traceback&quot;: str(traceback.format_exc())
        }
    logging.info(error_message)
</code></pre>
<p>And give me this error:</p>
<pre class="lang-py prettyprint-override"><code> File &quot;/home/airflow/.local/lib/python3.6/site-packages/airflow/kubernetes/pod_generator.py&quot;, line 272, in __init__
    for image_pull_secret in image_pull_secrets.split(','):
AttributeError: 'Secret' object has no attribute 'split'
</code></pre>
<p>Following this guide: <a href="https://airflow.readthedocs.io/en/latest/howto/operator/kubernetes.html" rel="nofollow noreferrer">https://airflow.readthedocs.io/en/latest/howto/operator/kubernetes.html</a></p>
<pre class="lang-py prettyprint-override"><code>from airflow import DAG
from datetime import datetime, timedelta
from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
from airflow.operators.dummy_operator import DummyOperator
from kubernetes.client import models as k8s
import logging
import os
import sys
import traceback 

try:

    default_args = {
        'owner': 'airflow',
        'depends_on_past': False,
        'start_date': datetime.utcnow(),
        'email': ['airflow@example.com'],
        'email_on_failure': False,
        'email_on_retry': False,
        'retries': 1,
        'retry_delay': timedelta(minutes=5)
    }

    dag = DAG(
        'jordi_test2', default_args=default_args, schedule_interval=timedelta(minutes=10))


    start = DummyOperator(task_id='run_this_first', dag=dag)

    
    quay_k8s = KubernetesPodOperator(
    namespace='default',
    name=&quot;passing-test7&quot;,
    image='docker.io/test-pai-1',
    image_pull_secrets=[k8s.V1LocalObjectReference('myregistrykey')],
    task_id=&quot;passing-task6&quot;,
    get_logs=True,
    dag=dag
)



    start &gt;&gt; quay_k8s

except Exception as e:

    error_message = {
            &quot;message&quot;: &quot;An internal error ocurred&quot;
            ,&quot;error&quot;: str(e)
            , &quot;error information&quot; : str(sys.exc_info())
            , &quot;traceback&quot;: str(traceback.format_exc())
        }
    logging.info(error_message)
</code></pre>
<p>But give me this error:</p>
<pre class="lang-py prettyprint-override"><code>for image_pull_secret in image_pull_secrets.split(','):
AttributeError: 'list' object has no attribute 'split'
</code></pre>
<p>If I go to the Airflow documentation for the KubernetesPodOperator: <a href="https://airflow.apache.org/docs/stable/_api/airflow/contrib/operators/kubernetes_pod_operator/index.html" rel="nofollow noreferrer">https://airflow.apache.org/docs/stable/_api/airflow/contrib/operators/kubernetes_pod_operator/index.html</a></p>
<p>Say:</p>
<pre class="lang-py prettyprint-override"><code> image_pull_secrets (str) – Any image pull secrets to be given to the pod. If more than one secret is required, provide a comma separated list: secret_a,secret_b
</code></pre>
<p>How is the correct way to write it?</p>

<p>Would ask for clarification as a comment but I don't have the reputation. So providing a solution with some assumptions.</p>
<ol>
<li>Since you provided documentation links to the latest version of Airflow I'll assume you are using that.</li>
<li>The code you posted is unaltered.</li>
</ol>
<p>Here your secret is named <strong>testquay</strong></p>
<blockquote>
<pre><code>kubectl create secret docker-registry testquay \
    --docker-server=quay.io \
    --docker-username=&lt;Profile name&gt; \
    --docker-password=&lt;password&gt;
</code></pre>
</blockquote>
<p>However you reference it as <em>myregistrykey</em> in the code you posted that is meant to follow the example you reference.</p>
<blockquote>
<pre><code>image_pull_secrets=[k8s.V1LocalObjectReference('myregistrykey')],
</code></pre>
</blockquote>
<p>It should reference the secret name according to the example.</p>
<pre><code>image_pull_secrets=[k8s.V1LocalObjectReference('testquay')],
</code></pre>
<p>Also for the first DAG code, I don't believe you can pass a <code>Secrets</code> object in that manner. Those are meant to be injected into the k8s pod either as a volume or env variable at runtime. <a href="https://github.com/apache/airflow/blob/v1-10-stable/airflow/kubernetes/secret.py#L35-L40" rel="nofollow noreferrer">https://github.com/apache/airflow/blob/v1-10-stable/airflow/kubernetes/secret.py#L35-L40</a></p>
