I have created an Autopilot cluster on GKE
I want to connect and manage it with Python Kubernetes Client
I am able to get the kubeconfig of cluster
I am able to access the cluster using kubectl on my local system using the command
gcloud container clusters get-credentials
When I try to connect with python-client-library of kubernetes, I get following error
File "lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xxx.xx.xxx.xxx', port=443): Max
retries exceeded with url: /apis/extensions/v1beta1/namespaces/default/ingresses (Caused by
SSLError(SSLError(136, '[X509] no certificate or crl found (_ssl.c:4140)')))
here is the code i am using
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "863924b908c7.json"
credentials, project = google.auth.default(
scopes=['https://www.googleapis.com/auth/cloud-platform', ])
credentials.refresh(google.auth.transport.requests.Request())
cluster_manager = ClusterManagerClient(credentials=credentials)
# cluster = cluster_manager.get_cluster(project)
config.load_kube_config('config.yaml')
Here's what I figured out. I think it's a good solution because it prevents man in the middle attacks (uses SSL) unlike other python snippets in the wild.