<p>For every command with <code>kubectl</code> I need to use <code>sudo kubectl</code>.  </p>

<p>I understand the security perspective but I am working on a test environment and I want to be able use it without <code>sudo</code>.  </p>

<p>I tried to run <code>sudo -i</code> and use the root account to run<code>kubectl get pods</code>  but I received:  </p>

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

<p>I noticed that when I was playing with <a href="https://labs.play-with-k8s.com" rel="noreferrer">https://labs.play-with-k8s.com</a>, the user is root and I can run <code>kubectl</code> freely.  </p>

<p>I wanted to have the same thing on my Ubuntu machine with my Minikube.  </p>

<p>When I run<code>kubectl get pods</code> with my regular account I received the error:  </p>

<pre><code>error: unable to read client-key /home/myuser/.minikube/client.key for minikube due to open /home/myuser/.minikube/client.key: permission denied
</code></pre>

<p>I supposed there are two ways:<br>
1. Give everyone access to <code>/home/myuser/.minikube/</code><br>
2. Give my account permissions to run <code>kubectl</code> without <code>sudo</code>    </p>

<p>EDIT:<br>
Following @Konstantin Vustin request, here are the requested information:  </p>

<pre><code>myuser@ubuntu:/usr/local/bin$ ls -l  $(which kubectl)
-rwxrwxr-x 1 myuser myuser 54308597 Jun 13 05:21 /usr/local/bin/kubectl

myuser@ubuntu:/usr/local/bin$ ls -la ~ | grep kube
drwxr-xr-x  5 myuser myuser   4096 Jun 17 02:25 .kube
drwxrwxr-x 10 myuser myuser   4096 Jun 13 05:18 .minikube

myuser@ubuntu:/usr/local/bin$ ls -l ~/.kube
total 24
drwxr-xr-x  3 root  root  4096 Jun 13 05:26 cache
-rw-------  1 myuser myuser 911 Jun 13 05:27 config
drwxrwxr-x  3 myuser myuser 4096 Jul 11 01:37 http-cache
</code></pre>

E235
<p><strong>Fix file permissions</strong></p>

<p>Most likely your kubectl files are not owned by your user.</p>

<p>You can set these permissions using below command.</p>

<pre><code>sudo chown -R $USER $HOME/.kube
</code></pre>

<p><strong>Run kubectl with sudo</strong></p>

<p>Alternatively you can run kubectl as sudo user using a <a href="https://www.sudo.ws/man/1.8.23/sudo.man.html#s" rel="noreferrer">persistent sudo shell</a>.</p>

<pre><code>sudo -s
</code></pre>

<p>then run your kubectl commands</p>

<pre><code>kubectl get pods

kubectl describe &lt;resource_type&gt; &lt;resource_name&gt;
</code></pre>

<p>finally exit the sudo shell</p>

<pre><code>exit
</code></pre>
