Skip to content

Commit 9ede38a

Browse files
authored
Change default value of namespace in task.kubernetes to be None (#43402)
* change default namespace value to be None * passing namespace to decorator when in_cluster=False * add breaking change * change changelog * revert ui change
1 parent e9bc557 commit 9ede38a

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

providers/src/airflow/providers/cncf/kubernetes/CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
Changelog
2828
---------
2929

30+
31+
main
32+
.....
33+
34+
.. warning::
35+
Set the default value of ``namespace`` in ``@task.kubernetes`` to ``None``, so it uses the cluster namespace when ``in_cluster`` is True. Be sure to specify a namespace when using this decorator. To retain the previous behavior, set ``namespace="default"``
36+
37+
3038
9.0.1
3139
.....
3240

providers/src/airflow/providers/cncf/kubernetes/decorators/kubernetes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class _KubernetesDecoratedOperator(DecoratedOperator, KubernetesPodOperator):
6565
# there are some cases we can't deepcopy the objects (e.g protobuf).
6666
shallow_copy_attrs: Sequence[str] = ("python_callable",)
6767

68-
def __init__(self, namespace: str = "default", use_dill: bool = False, **kwargs) -> None:
68+
def __init__(self, namespace: str | None = None, use_dill: bool = False, **kwargs) -> None:
6969
self.use_dill = use_dill
7070
super().__init__(
7171
namespace=namespace,

providers/src/airflow/providers/cncf/kubernetes/provider.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ state: ready
2525
source-date-epoch: 1730012271
2626
# note that those versions are maintained by release manager - do not update them manually
2727
versions:
28+
- 10.0.0
2829
- 9.0.1
2930
- 9.0.0
3031
- 8.4.2

providers/tests/cncf/kubernetes/decorators/test_kubernetes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def test_basic_kubernetes(dag_maker, session, mock_create_pod: mock.Mock, mock_h
7878
in_cluster=False,
7979
cluster_context="default",
8080
config_file="/tmp/fake_file",
81+
namespace="default",
8182
)
8283
def f():
8384
import random
@@ -122,6 +123,7 @@ def test_kubernetes_with_input_output(
122123
in_cluster=False,
123124
cluster_context="default",
124125
config_file="/tmp/fake_file",
126+
namespace="default",
125127
)
126128
def f(arg1, arg2, kwarg1=None, kwarg2=None):
127129
return {"key1": "value1", "key2": "value2"}

0 commit comments

Comments
 (0)