<p>I try to change default context in kubernetes but I get <code>config.lock: permission denied</code> error.</p>

<pre><code>$ kubectl config set-context $(kubectl config current-context) --namespace=custom_namespace 
error: open /home/vagrant/.kube/config.lock: permission denied
</code></pre>

<p>Make sure that <code>kubernetes config directory</code> has the same permissions as <code>kubernetes config file</code>.</p>
<p><strong>Solution</strong> Beside, steps specified in <a href="https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#more-information" rel="nofollow noreferrer">kubernetes documentation</a>.</p>
<pre><code>$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
</code></pre>
<p>Add change permissions on <code>$HOME/.kube/</code> directory.</p>
<pre><code>$ sudo chown -R $(id -u):$(id -g) $HOME/.kube/
</code></pre>
