Kubernetes task decorator default namespace behaves different than KubernetesPodOperator when in cluster #42957
Closed
1 of 2 tasks
Labels
area:core
good first issue
kind:bug
This is a clearly a bug
provider:cncf-kubernetes
Kubernetes provider related issues
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.9.2
What happened?
Given these settings for KuberneteseExecutor:
the behavior of
@task.kubernetes()
vsKubernetesOperator()
when not setting namespace differs:@task.kubernetes()
defaults tonamespace="default"
KuberntesPodOperator()
defaults tonamespace=None
which uses the cluster namespace whenin_cluster
is true.What you think should happen instead?
KubernetesPodOperator
and@task.kubernetes
should use the in-cluster namespace by default (i.e., the worker pod's namespace).How to reproduce
Use a namespace that isn't
default
, let's call itfoobar
for this exampleSet the service account to only allow pod API access to
foobar
namespace.Run this DAG
You'll see K8s API error for the wrong namespace. In my case, the KPO decorator is trying to access the
airflow
namespace despite the pod is running in the correct namespaceHere's the KPO decorator task's pod spec:
Operating System
Amazon Linux 2
Versions of Apache Airflow Providers
apache-airflow-providers-cncf-kubernetes==7.14.0
Deployment
Other 3rd-party Helm chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: