Skip to content

Commit

Permalink
Use default connection id for KubernetesPodOperator (apache#28848)
Browse files Browse the repository at this point in the history
* Use default connection id for KubernetesPodOperator

---------

Co-authored-by: Jed Cunningham <[email protected]>
Co-authored-by: eladkal <[email protected]>
  • Loading branch information
3 people authored Apr 8, 2023
1 parent a09fd0d commit 85b9135
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 72 deletions.
8 changes: 8 additions & 0 deletions airflow/providers/cncf/kubernetes/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
Changelog
---------

6.0.0
.....

Breaking changes
~~~~~~~~~~~~~~~~

Use kubernetes_default connection by default in the KubernetesPodOperator.

5.3.0
.....

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/cncf/kubernetes/operators/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class KubernetesPodOperator(BaseOperator):
def __init__(
self,
*,
kubernetes_conn_id: str | None = None, # 'kubernetes_default',
kubernetes_conn_id: str | None = KubernetesHook.default_conn_name,
namespace: str | None = None,
image: str | None = None,
name: str | None = None,
Expand Down
1 change: 1 addition & 0 deletions airflow/providers/cncf/kubernetes/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ description: |
suspended: false
versions:
- 6.0.0
- 5.3.0
- 5.2.2
- 5.2.1
Expand Down
18 changes: 2 additions & 16 deletions airflow/providers/cncf/kubernetes/utils/pod_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from urllib3.response import HTTPResponse

from airflow.exceptions import AirflowException
from airflow.kubernetes.kube_client import get_kube_client
from airflow.kubernetes.pod_generator import PodDefaults
from airflow.utils.log.logging_mixin import LoggingMixin
from airflow.utils.timezone import utcnow
Expand Down Expand Up @@ -219,28 +218,15 @@ class PodManager(LoggingMixin):

def __init__(
self,
kube_client: client.CoreV1Api = None,
in_cluster: bool = True,
cluster_context: str | None = None,
kube_client: client.CoreV1Api,
):
"""
Creates the launcher.
:param kube_client: kubernetes client
:param in_cluster: whether we are in cluster
:param cluster_context: context of the cluster
"""
super().__init__()
if kube_client:
self._client = kube_client
else:
self._client = get_kube_client(in_cluster=in_cluster, cluster_context=cluster_context)
warnings.warn(
"`kube_client` not supplied to PodManager. "
"This will be a required argument in a future release. "
"Please use KubernetesHook to create the client before calling.",
DeprecationWarning,
)
self._client = kube_client
self._watch = watch.Watch()

def run_pod_async(self, pod: V1Pod, **kwargs) -> V1Pod:
Expand Down
Loading

0 comments on commit 85b9135

Please sign in to comment.