mik-laj commented on a change in pull request #10453:
URL: https://github.com/apache/airflow/pull/10453#discussion_r487751104
##########
File path: airflow/providers/cncf/kubernetes/hooks/kubernetes.py
##########
@@ -36,32 +36,56 @@ class KubernetesHook(BaseHook):
"""
Creates Kubernetes API connection.
+ - use in cluster configuration by using ``extra__kubernetes__in_cluster``
in connection
+ - use custom configuration either by providing content of kubeconfig file
via
+ ``extra__kubernetes__kube_config`` in connection
+ - use custom config by providing path to the file using
``extra__kubernetes__kube_config_path``
+ - use default config by providing no extras
+
+ .. seealso::
+ For more information about Kubernetes connection:
+ :ref:`howto/connection:kubernetes`
+
:param conn_id: the connection to Kubernetes cluster
:type conn_id: str
"""
- def __init__(self, conn_id: str = "kubernetes_default"):
+ def __init__(
+ self, conn_id: str = "kubernetes_default", client_configuration:
Optional[client.Configuration] = None
+ ):
super().__init__()
self.conn_id = conn_id
+ self.client_configuration = client_configuration
def get_conn(self):
"""
Returns kubernetes api session for use with requests
"""
connection = self.get_connection(self.conn_id)
extras = connection.extra_dejson
+
+ kubeconfig_path = extras.get("extra__kubernetes__kube_config_path")
+ kubeconfig = extras.get("extra__kubernetes__kube_config")
+
if extras.get("extra__kubernetes__in_cluster"):
Review comment:
There are 4 connection setup methods. One when the configuration is
empty, but the next 3 options are mutually exclusive - `kubeconfig_path`,
`kubeconfig`, `in_cluster`.
You cannot define a configuration that contains the following sets of
options:
- `in_cluster` and `kubeconfig`,
- `in_cluster` and `kubeconfig_path`,
- `kubeconfig` and `kubeconfig_path`.
If someone tries to use such a configuration, I think it is worth warning
the user that they have a wrong configuration, because we are not able to
determine the correct variant, because we only load one variant.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]