Kubernetes permission denied error on config.lock

12/11/2018

I try to change default context in kubernetes but I get config.lock: permission denied error.

$ kubectl config set-context $(kubectl config current-context) --namespace=custom_namespace 
error: open /home/vagrant/.kube/config.lock: permission denied
-- Lukasz Dynowski
kubernetes

2 Answers

9/4/2019

if you are on windows system. try to run command as administrator.

this fix error. open .lock: access is denied.

-- RyanShao
Source: StackOverflow

12/11/2018

Make sure that kubernetes config directory has the same permissions as kubernetes config file.

Solution Beside, steps specified in kubernetes documentation.

$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

Add change permissions on $HOME/.kube/ directory.

$ sudo chown $(id -u):$(id -g) $HOME/.kube/
-- Lukasz Dynowski
Source: StackOverflow