debugMajor
error: error loading config file "/etc/rancher/k3s/k3s.yaml": open /etc/rancher/k3s/k3s.yaml: permission denied
Viewed 0 times
rancherfileerrork3sopenpermissiondeniedconfigloadingyaml
Problem
When I run commands under
How should I resolve this? Should I change the permissions of
k3s kubectl, I get$ k3s kubectl version
WARN[0000] Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify kube config permissions
error: error loading config file "/etc/rancher/k3s/k3s.yaml" : open /etc/rancher/k3s/k3s.yaml: permission denied
How should I resolve this? Should I change the permissions of
/etc/rancher/k3s/k3s.yamlSolution
No, do not change permissions of
First set up your an environmental variable for
Then let's generate the file at that location. Your
You can add
/etc/rancher/k3s/k3s.yamlFirst set up your an environmental variable for
KUBECONFIG=~/.kube/config.export KUBECONFIG=~/.kube/configThen let's generate the file at that location. Your
k3s.yaml file should NOT be world readable.. This is by-design. It should be owned by root and set to 0600. Instead copy the config locally as described here,mkdir ~/.kube 2> /dev/null
sudo k3s kubectl config view --raw > "$KUBECONFIG"
chmod 600 "$KUBECONFIG"
You can add
KUBECONFIG=~/.kube/config to your ~/.profile or ~/.bashrc to make it persist on reboot.Code Snippets
export KUBECONFIG=~/.kube/configContext
StackExchange DevOps Q#16043, answer score: 22
Revisions (0)
No revisions yet.