<p>i am trying GCP and GKE google kubernetes engine.
1-)i am create a cluster
2-)i opened cloud shell and used command &quot;kubectl get nodes&quot;</p>
<p>i get this error:
&quot;The connection to the server localhost:8080 was refused - did you specify the right host or port?&quot;</p>
<p>how can i solve. thanks.</p>

gokhandincel
<p>You must have a local Kubernetes config file that is used by <code>kubectl</code> to access cluster(s).</p>
<p>Conventionally, the config file is called <code>config</code> (YAML) and is found in <code>${HOME}/.kube/config</code>.</p>
<p>Google provides a way to generate a config file (and context) for you. To do this run <code>gcloud container clusters get-credentials ...</code>. You'll need to fill in the blanks of the cluster name and probably the project, zone/region etc.:</p>
<pre class="lang-sh prettyprint-override"><code>gcloud container clusters get-credentials ${CLUSTER_NAME} \
--project=${PROJECT} \
--region=${REGION}
</code></pre>
<p>After running this command, you should be able to <code>more ${HOME}/.kube/config</code> and you should be able to access the cluster using e.g. <code>kubectl get nodes</code>.</p>
