0

We have a functioning GKE cluster to which I wish to make changes but I am unable to connect to the cluster using kubectl in order to make those changes. I have attempted to connect using the cloud shell in the GCP console:

jamie_thomson@cloudshell:~ (myproject)$ gcloud container clusters get-credentials clustername --region europe-west2 --project myproject
Fetching cluster endpoint and auth data.
kubeconfig entry generated for clustername.
jamie_thomson@cloudshell:~ (myproject)$ kubectl get pods
Unable to connect to the server: dial tcp <IP redacted>:443: i/o timeout

The IP address mentioned in the error message is the same Ip address given in the GCP console as the cluster's external endpoint.

Given I am using cloud shell I would have thought I would be able to successfully establish a connection but alas I cannot. I would appreciate any advice on how I can solve this connectivity problem.

jamiet
  • 10,501
  • 14
  • 80
  • 159

1 Answers1

1

This will happen when kubectl is unable to communicate with the cluster control plane.Verify the context where the cluster is set in order to resolve this issue.

To make sure the configuration file has the cluster context and the control plane's external IP address, navigate to $HOME/.kube/config or use the kubectl config view command.

If the cluster context is not set properly set the context using following command

kubectl config set-context context-name --user=username

For more detailed troubleshooting refer to this gcp document

Refer this SO link which helped in resolving the same error while using cloud shell and GKE.