<p>When I want to execute this command:</p>

<pre><code>kubectl apply -f namespace.yaml
</code></pre>

<p>I had this error message:</p>

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

<p>Some answers have been posted in Stackoverflow like using <code>kubectl</code> with:</p>

<pre><code>--kubeconfig=~/.kube/config
</code></pre>

<p>But this didn't solve my problem.</p>

<p>This is my <code>namespace.yaml</code> file:</p>

<pre><code>apiVersion: v1
kind: Namespace
metadata:
  name: my_namespace
</code></pre>

<p>I'm using GKE (1.10.6-gke.3).</p>

4m1nh4j1
<p>You need to configure kubectl to use your cluster as described here: <a href="https://cloud.google.com/kubernetes-engine/docs/quickstart" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/quickstart</a></p>
