diff --git a/airflow/contrib/operators/kubernetes_pod_operator.py b/airflow/contrib/operators/kubernetes_pod_operator.py index 34c7fc79c9914..981500d5e688a 100644 --- a/airflow/contrib/operators/kubernetes_pod_operator.py +++ b/airflow/contrib/operators/kubernetes_pod_operator.py @@ -147,7 +147,7 @@ def __init__(self, # pylint: disable=too-many-arguments,too-many-locals volumes: Optional[List[Volume]] = None, env_vars: Optional[Dict] = None, secrets: Optional[List[Secret]] = None, - in_cluster: bool = True, + in_cluster: Optional[bool] = None, cluster_context: Optional[str] = None, labels: Optional[Dict] = None, startup_timeout_seconds: int = 120, @@ -215,9 +215,13 @@ def __init__(self, # pylint: disable=too-many-arguments,too-many-locals def execute(self, context): try: - client = kube_client.get_kube_client(in_cluster=self.in_cluster, - cluster_context=self.cluster_context, - config_file=self.config_file) + if self.in_cluster is not None: + client = kube_client.get_kube_client(in_cluster=self.in_cluster, + cluster_context=self.cluster_context, + config_file=self.config_file) + else: + client = kube_client.get_kube_client(cluster_context=self.cluster_context, + config_file=self.config_file) # Add Airflow Version to the label # And a label to identify that pod is launched by KubernetesPodOperator