Kubernetes is a nice offering on Google Cloud Platform. It is pretty easy to create a Kubernetes cluster and deploy software to the cluster. I recently run into a weird issue in using Kubernetes and would like to share my issue and solution in this blog.
I run kubectl get nodes command after creating a new Kubernetes cluster. It usually works without any issue. This time when I run it, it look hung and came back the following error after long time.
wzhou:@myhost tmp > kubectl get nodes Unable to connect to the server: dial tcp 184.108.40.206:443: i/o timeout
It looked weird as I didn’t do anything significantly different than my other runs. After went through the steps I created the cluster, I realized I created the cluster in a different zone this time. Ok, let me try to get the credential for my cluster, wz-kube1.
wzhou:@myhost tmp > gcloud container clusters get-credentials wz-kube1 Fetching cluster endpoint and auth data. ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=404, message=The resource "projects/cdh-gcp-test-139878/zones/us-central1-a/clusters/wz-kube1" was not found. Could not find [wz-kube1] in [us-central1-a]. Did you mean [wz-kube1] in [us-east1-b]?
Ah, this indicated the issue. Let me specify the zone again and no error this time.
wzhou:@myhost tmp > gcloud container clusters get-credentials wz-kube1 --zone us-east1-b Fetching cluster endpoint and auth data. kubeconfig entry generated for wz-kube1.
Try the get nodes command again. It worked this time. Problem solved.
wzhou:@myhost tmp > kubectl get nodes NAME STATUS ROLES AGE VERSION gke-wz-kube1-default-pool-6d1150c9-dcqf Ready <none> 47m v1.8.8-gke.0 gke-wz-kube1-default-pool-6d1150c9-dgfk Ready <none> 47m v1.8.8-gke.0 gke-wz-kube1-default-pool-6d1150c9-nfs7 Ready <none> 47m v1.8.8-gke.0