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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With