<p>I am going through the kubernetes tutorial at Udacity. When i run the the nginx image using the following command </p>

<pre><code>kubectl run nginx --image=nginx:1.10.0
</code></pre>

<p>It given me the error </p>

<blockquote>
  <p>error: failed to discover supported resources: Get <a href="http://localhost:8080/apis/extensions/v1beta1" rel="noreferrer">http://localhost:8080/apis/extensions/v1beta1</a>: dial tcp 127.0.0.1:8080: getsockopt: connection refused</p>
</blockquote>

<p>If i try to get pods using the following command</p>

<pre><code>kubectl get pods
</code></pre>

<p>it says</p>

<blockquote>
  <p>The connection to the server localhost:8080 was refused - did you specify the right host or port?</p>
</blockquote>

<p>The nginx server is running, i can tell because i can get the appropriate output by running curl <a href="http://127.0.0.1" rel="noreferrer">http://127.0.0.1</a></p>

<p>I am not able to figure out what the issue is, and there are not a lot of resources on the internet for this problem. Can anyone please tell me how do i resolve it?</p>

sid0972
<p>This issue often occurs when <code>kubectl</code> can not find the configuration credential for the intended cluster.</p>

<p>Check <code>$HOME/.kube/config</code> for cluster configuration. If configuration is empty or configuration is set for a wrong cluster, regenerate configuration by running,</p>

<pre><code>gcloud container clusters get-credentials &lt;CLUSTER_NAME&gt; --zone &lt;ZONE&gt;
</code></pre>

<p>This will update the configuration credential in <code>$HOME/.kube/config</code>.</p>

<p>Now, everything should work as expected.</p>

<p>Reference: <a href="https://github.com/googlecodelabs/feedback/issues/537" rel="noreferrer">https://github.com/googlecodelabs/feedback/issues/537</a></p>
