Apache Airflow version
2.6.1
What happened
Seem to be unable to specify dns_config in KubernetesPodOperator, despite it being an argument.
Broken DAG: [/opt/airflow/dags/repo/bug-report-dag.py] Traceback (most recent call last): File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 429, in apply_defaults result = func(self, **kwargs, default_args=default_args) File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 789, in __init__ f"Invalid arguments were passed to {self.__class__.__name__} (task_id: {task_id}). " airflow.exceptions.AirflowException: Invalid arguments were passed to KubernetesPodOperator (task_id: task). Invalid arguments were: **kwargs: {'dns_config': {'nameservers': None, 'options': None, 'searches': ['mydomain.com']}}
What you think should happen instead
dnsConfig should be correctly added to the pod manifest
How to reproduce
from airflow import DAG
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from airflow.utils.dates import days_ago
from kubernetes.client import models as k8s
default_args = {
'owner': 'airflow'
}
env = [
k8s.V1EnvVar(name="TEST_ARG", value="test")
]
dns = k8s.V1PodDNSConfig(searches=["mydomain.com"])
with DAG(
dag_id='my-dag',
default_args=default_args,
schedule_interval="*/5 * * * *",
start_date=days_ago(2),
catchup=False,
tags=['k8s-pod-operator','example', 'python'],
) as dag:
k = KubernetesPodOperator(
namespace='airflow',
image="python",
cmds=["python", "-c"],
arguments=["print('hello ...')"],
name="k8s-pod",
task_id="task",
env_vars=env,
dns_config=dns,
is_delete_operator_pod=True,
hostnetwork=False,
startup_timeout_seconds=1000,
kubernetes_conn_id=None
)
Operating System
Debian GNU/Linux 11 (bullseye)
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
Official helm chart via flux with
defaultAirflowTag: "2.6.1"
airflowVersion: "2.6.1"
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
2.6.1
What happened
Seem to be unable to specify dns_config in KubernetesPodOperator, despite it being an argument.
Broken DAG: [/opt/airflow/dags/repo/bug-report-dag.py] Traceback (most recent call last): File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 429, in apply_defaults result = func(self, **kwargs, default_args=default_args) File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 789, in __init__ f"Invalid arguments were passed to {self.__class__.__name__} (task_id: {task_id}). " airflow.exceptions.AirflowException: Invalid arguments were passed to KubernetesPodOperator (task_id: task). Invalid arguments were: **kwargs: {'dns_config': {'nameservers': None, 'options': None, 'searches': ['mydomain.com']}}What you think should happen instead
dnsConfig should be correctly added to the pod manifest
How to reproduce
Operating System
Debian GNU/Linux 11 (bullseye)
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
Official helm chart via flux with
defaultAirflowTag: "2.6.1"
airflowVersion: "2.6.1"
Anything else
No response
Are you willing to submit PR?
Code of Conduct