Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCP GKE Google Kubernetes Engine The connection to the server localhost:8080 was refused

i am trying GCP and GKE google kubernetes engine. 1-)i am create a cluster 2-)i opened cloud shell and used command "kubectl get nodes"

i get this error: "The connection to the server localhost:8080 was refused - did you specify the right host or port?"

how can i solve. thanks.

like image 593
gokhandincel Avatar asked Dec 11 '25 21:12

gokhandincel


1 Answers

You must have a local Kubernetes config file that is used by kubectl to access cluster(s).

Conventionally, the config file is called config (YAML) and is found in ${HOME}/.kube/config.

Google provides a way to generate a config file (and context) for you. To do this run gcloud container clusters get-credentials .... You'll need to fill in the blanks of the cluster name and probably the project, zone/region etc.:

gcloud container clusters get-credentials ${CLUSTER_NAME} \
--project=${PROJECT} \
--region=${REGION}

After running this command, you should be able to more ${HOME}/.kube/config and you should be able to access the cluster using e.g. kubectl get nodes.

like image 129
DazWilkin Avatar answered Dec 13 '25 10:12

DazWilkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!