Error Error Loading Config File Etc Rancher K3S
-
Teams
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
https://devops.stackexchange.com/questions/16043/error-error-loading-config-file-etc-rancher-k3s-k3s-yaml-open-etc-rancher
When I run commands under 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.yaml
asked May 31, 2022 at 19:53
](https://devops.stackexchange.com/users/18965/evan-carroll)
2,611
66 gold badges
3333 silver badges
8181 bronze badges
2 Answers
Sorted by:
32
No, do not change permissions of /etc/rancher/k3s/k3s.yaml
First set up your an environmental variable for KUBECONFIG=~/.kube/config.
export KUBECONFIG=~/.kube/config
Then 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 export KUBECONFIG=~/.kube/config to your ~/.profile or ~/.bashrc to make it persist on reboot.
](https://devops.stackexchange.com/users/44615/emil-carpenter)
103
33 bronze badges
answered May 31, 2022 at 19:53
](https://devops.stackexchange.com/users/18965/evan-carroll)
2,611
66 gold badges
3333 silver badges
8181 bronze badges
-
If the “sudo k3s kubectl …” line is giving an error stating “sudo: k3s: command not found”, then you can try by adding
/usr/local/bin/in front of “k3s”. Which would make that line as this:sudo /usr/local/bin/k3s kubectl config view --raw > "$KUBECONFIG" -
@UNOPARATOR the only way that could make a difference is if
/usr/local/binis not in your$PATHwhich would be pretty awkward anyway. -
In my case with a CentOS 8 Stream server, after the k3s installation that line wasn’t working. There was no mention of adding that to
$PATHbut it might be considered common practice and not mentioned because of that. I’m no linux expert of any kind, just commented in case someone like me encounters the same issue. -
When you run
echo $PATHyou should see/usr/local/binin your path. Almost certainly CentOS does that. (also, CentOS is dead, everyone went to Rocky). -
1
@UNOPARATOR, the problem is that on CentOS by default
sudowill use a PATH value different from your own PATH. This other value does not include/usr/local/bin, which is why it couldn’t find thek3scommand. One way to resolve this is to add/usr/local/binto thesecure_pathoption in/etc/sudoers. See superuser.com/questions/927512/… for details. Ubuntu and Debian do not have this issue (secure_pathincludes/usr/local/bin).
0
Prefix you command with sudo.
Run:
sudo k3s kubectl version
answered May 22 at 21:43
](https://devops.stackexchange.com/users/45321/user10339671)
1
Your Answer
Sign up or log in
Sign up using Google
Sign up using Email and Password
Post as a guest
Name
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
##
Not the answer you’re looking for? Browse other questions tagged
- The Overflow Blog
- Featured on Meta
-
The December 2024 Community Asks Sprint has been moved to March 2025 (and…
- Stack Overflow Jobs is expanding to more countries
Linked
6k3s: The connection to the server localhost:8080 was refused - did you specify the right host or port?
1With kubectl, I’m getting Unable to connect to the server: x509: certificate signed by unknown authority
-1How can I get an installation of k3s working with KubeApps?
Related
0Does /etc/rancher/k3s/registries.yaml affect `k3s ctr` and `k3s crictl`?
Hot Network Questions
- adduser allows weak password - how to prevent?
- Is SQL Injection possible if we’re using only the IN keyword (no equals = operator) and we handle the single quote
- Understanding the phrase halacha l’Moshe mi’Sinai
- Energy stored in EM fields are non-retrievable?
- Do accidentals have other meanings, or is their usage in this hymn all wrong?
- Joining two lists by matching elements of the two
- Why do some installers insist on not doing a full frame window replacement?
- Does fringe biology inspire fringe philosophy?
- Why does David Copperfield say he is born on a Friday rather than a Saturday?
- Is there a way I can enforce verification of an EC signature at design-time rather than implementation-time?
- Snowshoe design for satyrs and fauns
- Finding corners where multiple polygons meet in QGIS
- Horror Film about a streamer convention set at a hotel where a tragedy had taken place
- Which accents *don’t* merge FIRE and HIRE? What about RITE and RIDE?
- How to deal with academic loneliness?
- Is it normal for cabinet nominees to meet with senators before hearings?
- Iterating through a set of sublists to find some desired sublists
- Why are there no no-attribution licences other than “public domain”?
- Handling a customer that is contacting my subordinates on LinkedIn demanding a refund (already given)?
- World split into pocket dimensions; protagonist escapes from windowless room, later lives in abandoned city and raids a supermarket
- What can I do about a Schengen visa refusal from Greece that mentions a prior refusal from Sweden as the reason?
- centre text in a cell
- Why is Young’s modulus represented as a single value in DFT calculations?
- How to Mitigate Risks Before Delivering a Project with Limited Testing?
DevOps
Company
Stack Exchange Network
- Technology
- Culture & recreation
- Life & arts
- Science
- Professional
- Business
- API
- Blog
Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.12.18.20664