Every time I run a command in the kubernetes cluster I get the following error message: unable to connect to the server: dial tcp server_ip: i/o timeout
I’ve already followed the step by step to try to solve the problem described here: https://cloud.google.com/kubernetes-engine/docs/troubleshooting#kubectl-times-out, but it didn’t solve the problem
Has anyone had this problem?
I ran the command kubectl get nodes -v=10 to try to see more information about the error, but the return only shows a timeout command output
in this image I’m inside the cluster
in my case what I need to do is update some resources using kubectl apply -f my_file.yaml
Pedro Henrique is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
First, could you please let me know where you are running the commands from? Is it a cloud shell, local machine, or a VM instance?
There are multiple scenarios that can cause this error depending on the cluster environments. Some of the frequently occurring scenarios include:
- kubectl is unable to communicate with the cluster control plane or does not exist.
- The source IP is not allowed in the ‘Control plane authorized networks’ configuration of the cluster.
Based on your post, I assume you have added the Control Plane authorized networks. However, there’s a possibility that the GKE cluster context is not correctly configured on the source machine.
Ex: The GKE cluster context or the endpoint IP is incorrect on the kube config file ($HOME/.kube/config).
To resolve this issue, verify the context where the cluster is set: Navigate to $HOME/.kube/config or execute the command kubectl config view to ensure the configuration file contains the correct cluster context and the external IP address of the control plane.
Example to view the current/active cluster context used by kubectl command and verify the cluster endpoint IP.
kubectl config view --minify
After checking the config file, If there is something wrong with the current context like invalid IP, you might want to recreate it by using the following gcloud command.
gcloud container clusters get-credentials <CLUSTER_NAME> --region=<COMPUTE_REGION> --project=<PROJECT_ID>
Replace the following:
CLUSTER_NAME: the name of your cluster.
COMPUTE_REGION: the Compute Engine region for your cluster. For zonal clusters, use –zone=COMPUTE_ZONE.
PROJECT_ID: the ID of the project in which the GKE cluster was created