Kubernetes permission denied error on config.lock
12,324
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/
Related videos on Youtube
Author by
Lukasz Dynowski
Engineering for living, programming for fun. In one sentence, being immersed in Software Engineering. What about you? What’s your Kung-Foo?
Updated on September 14, 2022Comments
-
Lukasz Dynowski over 1 year
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
-
Jeff Saremi almost 5 yearsHad to use chown -R
-
semural about 4 years@Lukasz, what about for jenkins user? I am facing similar error while switching context in jenkins. I stored config file as a secret therefore there is no any config file $HOME/.kube
-
Lukasz Dynowski about 4 yearsI assume that you want to automatize deployments with jenkins.io and that a jenkins user has no home directory. Then, what if you create a home directory for jenkins user? Theoretically, you should solve this problem. On side, I've done automatic deployments yet so my knowledge of this subject is limited at this point.
-
lindhe about 2 yearsIt is not good practice running commands as a privileged user unnecessarily (mainly for security reasons). Running
kubectl
should usually not require running as administrator.