only use get_default_copy method if it exists
@@ -46,7 +46,11 @@ def login_via_client(
raise credentials.LoginError(f"Cannot authenticate client neither in-cluster, nor via kubeconfig.")
# We do not even try to understand how it works and why. Just load it, and extract the results.
+ # For kubernetes client >= 12.0.0 use the new 'get_default_copy' method
+ if callable(getattr(kubernetes.client.Configuration, 'get_default_copy', None)):
config = kubernetes.client.Configuration.get_default_copy()
+ else:
+ config = kubernetes.client.Configuration()
# For auth-providers, this method is monkey-patched with the auth-provider's one.
# We need the actual auth-provider's token, so we call it instead of accessing api_key.
