<p>On my master node</p>

<pre><code>root@k8smaster:~# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?
root@k8smaster:~# exit
logout

yoda@k8smaster:~/bin$ kubectl get nodes
NAME        STATUS    ROLES     AGE       VERSION
k8smaster   Ready     master    5d        v1.9.2
k8sworker   Ready     &lt;none&gt;    51s       v1.9.2
</code></pre>

<p>Why do I need to run kubectl as my own user ? </p>

<p>What Michael said is exactly accurate; <code>kubectl</code> looks in the <em>current user's</em> home directory, which for <code>yoda</code> will likely be <code>/home/yoda</code> but for root is almost certainly <code>/root</code>.</p>

<p>You can very quickly test this theory by re-running your <code>kubectl</code> command with an explicit <code>--kubeconfig ~yoda/.kube/config</code>:</p>

<pre><code>kubectl --kubeconfig ~yoda/.kube/config get nodes
</code></pre>

<p>You can also export the shell variable <code>KUBECONFIG</code> to avoid having to constantly include that long <code>--kubeconfig</code> syntax:</p>

<pre><code>export KUBECONFIG=~yoda/.kube/config
kubectl get nodes
</code></pre>

<p>Ensure you don't put any characters between the <code>~</code> and <code>yoda</code> or it will look for a <code>yoda</code> directory inside the current user's home directory.</p>
