简体   繁体   中英

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

i am trying GCP and GKE google kube.netes 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.

You must have a local Kube.netes 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 eg kubectl get nodes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM