title: airflow - dynamically change namespace in KubernetesPodOperator
body: <p>I am running airflow 1.10.13 on kubernetes and trying to find a way to dynamically change the namespace I run a task on.
  I tried using templates and inserting parameters from the dag_run.conf json but the template is only rendered in the 'cmds' and not in other task fields like namespace.</p>
  <p>I would love to find a solution (using templates or any other way) to alter the namespace.</p>
  <pre><code>default_args = {
      'owner': 'airflow',
      'start_date': days_ago(1)
  }
  
  with DAG('test_ns', default_args=default_args, schedule_interval='@once') as dag:
      ns = &quot;&quot;&quot; {{ dag_run.conf.ns }} &quot;&quot;&quot;
      example_task= KubernetesPodOperator(namespace=ns,
                                           image='python:3.6',
                                           cmds=[&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo {{ns}}&quot;],
                                           arguments=[],
                                           task_id='example_task',
                                           name='example_task',
                                           get_logs=True,
                                           is_delete_operator_pod=True,
                                           provide_context=True
                                           )
  </code></pre>