<p>I have KUBECONFIG inside my .kube/ folder still facing this issue.</p>

<p>I have also tried</p>

<pre><code>kubectl config set-context ~/.kube/kubeconfig.yml

kubectl config use-context ~/.kube/kubeconfig.yml
</code></pre>

<p>No luck! Still the same.</p>

Rajat jain
<p><em>Answering my own question</em></p>

<p>Initially, I had lost a lot of time on this error, but later I found that my kubeconfig is not having the correct context.</p>

<p>I tried the same steps: </p>

<pre><code>kubectl config set-context ~/.kube/kubeconfig1.yml

kubectl config use-context ~/.kube/kubeconfig1.yml
</code></pre>

<p>or add a line with kubeconfig to your <code>~/.bashrc</code> file</p>

<pre><code>export KUBECONFIG=~/.kube/&lt;kubeconfig_env&gt;.yml
</code></pre>

<p>Also, if you want to add multiple kubeconfig: Add it like in <code>~/.bashrc</code> file</p>

<pre><code>export KUBECONFIG=~/.kube/kubeconfig_dev.yml:~/.kube/kubeconfig_dev1.yml:~/.kube/kubeconfig_dev2.yml
</code></pre>

<p>with different Kube contexts and it worked well. </p>

<p><em>Though the error should simplify and return the specific error related to kubecontext.</em></p>

<p>But after some digging it worked.</p>
