kubectl get componentstatus Unable to connect to the server: dial tcp xx.xxx.xx.x:xxx: i/o timeout

9/5/2020

while I'm trying to get the pods or node states , from GCP Cloud Shell, I'm facing this error? can someone please help me? but i can see the output of the "kubectl config view" .

-- Yuva Yuva
google-cloud-platform
google-kubernetes-engine
kubectl

1 Answer

9/7/2020

Posting this answer as community wiki for better visibility and the fact that the possible solution was posted in the comments:

Does this answer your question? Unable to connect to the server: dial tcp i/o time out


Adding to that:

Below command:

  • $ kubectl config view

is used to show the configuration stored in your ./kube/config file. The fact that you can see the output of this command doesn't mean you have correct cluster configured to use with kubectl.


From the perspective of Google Cloud Platform and Cloud Shell

There is an official documentation regarding troubleshooting issues with GKE:

There could be several reasons why you are getting following error:

  • You are referencing wrong cluster in your ~/.kube/config file.
    • $ gcloud container cluster get-credentials CLUSTER_NAME --zone=ZONE - you will need to run this command to fetch the correct configuration
    • You can also get above command from the Kubernetes Engine page (Connect button)
  • You are referencing a cluster in your ~/.kube/config file that was deleted
  • You created Private GKE cluster

For more information you can look in the Cloud Console -> Kubernetes Engine -> CLUSTER_NAME

You can also run:

  • $ gcloud container clusters list - this command will show clusters and their state (status) they are in
  • $ gcloud container clusters describe CLUSTER_NAME --zone=ZONE - this command will show you the configuration of the cluster
-- Dawid Kruk
Source: StackOverflow