I am doing some tutorials from https://codelabs.developers.google.com/codelabs/cloud-springboot-kubernetes?continue=https%3A%2F%2Fdevelopers.google.com%2Flearn%2Fpathways%2Fjava-cloud-fundamentals%23codelab-https%3A%2F%2Fcodelabs.developers.google.com%2Fcodelabs%2Fcloud-springboot-kubernetes#5. I am using Google Cloud Console. When I type:
kubectl version
I am getting an response:
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:20:07Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Unable to connect to the server: dial tcp 34.135.56.138:443: i/o timeout
What I do not like is the
Unable to connect to the server: dial tcp 34.135.56.138:443: i/o timeout
I am getting this error also when running other kubectl commands, which stops my progress. I am using only out of the box tools provided by Google Cloud. What is causing this error in Google Cloud Console? Do I need to make additional Kubernetes configuration? (The tutorial did not mention anything like that)
Running the command as suggested in the comments:
gcloud container clusters get-credentials hello-java-cluster --zone=us-central1-c
I am getting an error:
Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=404, message=Not found: projects/question-tracker/zones/us-central1-c/clusters/hello-java-cluster.
No cluster named 'hello-java-cluster' in question-tracker.
EDIT: I have run the command: (instead of hello-java-cluster I ran it with previously created questy-java-cluster)
(quizdev)$ gcloud container clusters get-credentials questy-java-cluster --zone=us-central1-c
And it ran without error giving result:
Fetching cluster endpoint and auth data.
kubeconfig entry generated for questy-java-cluster.
After this operation kubectl version runs in 1 second and does not give the error.
There are 2 steps that get blurred by gcloud
into one.
The gcloud container clusters create
command not only creates the cluster but it also configures kubectl
via kubeconfig (~/.kube/config
) to access the cluster.
If you're unable to e.g. kubectl get nodes
after gcloud container clusters create
and you're confident the cluster created successfully (i.e. by checking Cloud Console), it may be that the kubeconfig file was not correctly configured.
Please confirm that the kubeconfig file in the default location (~/.kube/config) exists and contains data (cluster
, server
, user
) entries correspondonging to your cluster.
If that all looks good, you can try repeating the step that configures kubeconfig: gcloud container clusters get-credentials hello-java-cluster --zone=us-central1-c
. If there are any other errors running these commands, please edit your question and include the errors.
If you've changed the cluster's {NAME}
, {LOCATION}
or are using a different Google Cloud {PROJECT}
, please use these (replacing with the correct values) in the above command:
gcloud container clusters get-credentials ${NAME} \
--location=${LOCATION} \
--project=${PROJECT}