-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/etc/rancher/k3s/k3s.yaml is world readable #389
Comments
Yeah, we actually did this on purpose but I can see how people wouldn't like it. You can change the file mode of the kubeconfig as a parameter in |
That sounds reasonable to me.
Did you mean "unless they are root"? (Just making sure I understand your explanation.) |
I think what I'd like to do here is make the file not world readable and then change the kubectl wrapper code in k3s to try to read /etc/rancher/k3s/k3s.yaml and if it's not accesible issue a warning. kubectl might still fail but it will at least help the user to know that maybe they need to run as root. In the warning message we can indicate the server can be launch with |
Version - v0.6.0-rc3 |
For most installations now all Also, there seems to be no documentation around |
Same here. I was caught unaware and updated one of my clusters, and |
Hi all, I found how to use the new flag:
|
I think this broke the quick start on https://k3s.io/ curl -sfL https://get.k3s.io | sh - |
For others struggling with this still (when using the quick run install script on CentOS 7 like me): The command as-is installs fine, but kubectl won't work without using sudo. However, default sudo setup in CentOS 7 does not let you use the default kubectl path. As noted by @mattiaperi above, you can use the My solution was to install via default method, and just use visudo to edit the secure_path variable to include /usr/local/bin Seems to be working fine. |
Note that if you just want to allow access in an already existing install you can edit the |
the above failed to for me on exsting cluster.. i just updated the permission on the file and it seemed to do the trick /etc/rancher/k3s $ sudo chmod 777 k3s.yaml |
You do have to restart the service if you are trying to change the perms via env variable or command line option. It rewrites the file and sets permissions on startup. |
Just do: |
For who installed k3s with binary, using |
Run this as root on existing installation (Ubuntu 20.04 LTS)
|
|
One more option to install and set flag
|
If you're using k3sup to install k3s, add this flag to your install Note: You may run into issues if you use this on your agents, I hit this error: |
Adding a comment to try and stop users unwittingly using these If you really do need admin |
Based on @jr200 comment, here's a one liner that copies the
This preserves the existing 600 permissions of If you prefer a single kubeconfig, you can merge If you have no existing
|
worked for me. Thanks @Panoptik |
curl -sfL https://get.k3s.io | sh -
# Check for Ready node, takes maybe 30 seconds
k3s kubectl get node It's frustrating to see this on the landing page of k3s.io - This won't take long… oooookay. You could find many results based on the error The setup procedure should be updated. Otherwise it won't work just out of the box. |
The very basic quick start instructions do assume you're root. Some folks want it world readable, others don't - the latter makes more sense from a security perspective. Hopefully anyone attempting to use Kubernetes knows how to deal with file permissions or use sudo. |
The more common solution for this problem by the installer - real fix to me: /etc/systemd/system/k3s.service.env: /etc/profile.d/k3s.sh /etc/profile.d/k3s.csh done. |
IMHO k3s is designed to be used in the deployment of kubernetes clusters in many different environments (cloud, bare-metal, raspberry pi). This default behavior fits well with this usage. For a k3s local development environment, rancher-desktop is pretty easy to get up and running, but I dont like using the kvm intermediary on linux (its great on mac and windows), and, at least for now it does not allow access to Ingress via localhost (it does on mac and windows) which I raised an issue about in the rancher-desktop github repo. I would prefer to be able to set up a native k3s for local development on linux which allows localhost access to Ingress/ |
This suggestion seems to have been forgotten, but I can confirm that doing this post-installation works just fine (all commands run as root):
EDIT: Cancel that - apparently the permissions of |
@scubbo I found your solution works just fine, except that I am using the solution in the comment above (#389 (comment)) to change file permissions with flag |
Just to note a sister issue with this: In Ubuntu, apparently the default security settings won't allow keeping the permissions for the file set to 644. If I set I don't claim to know what to do about this one, but it may be worth an entry in the docs if an Ubuntu SME has any insight. |
the permissions are only reset to whatever mode is set by |
I noticed one thing just today. This only happens on under-resourced agents and servers. I'm developing an AI system and am resource constrained. I see that when the VMs hosting servers and agents are at 80%+ memory pressure and other saturation, this issue happens repeatedly, but if I over-provision the VMs, this doesn't happen at all. |
So yeah, the systems are under-resourced and k3s is crashing and restarting? |
Other than latency and the file permissions of this file changing, I never say saw evidence of the agent or server restarting, but I suppose this is what was happening. I will remember the flag --write-kubeconfig-mode mentioned in the conversation and set that to 644 moving forward. Sorry to take up the team's time on this one, but hopefully this thread is helpful to others in the future. |
Installing k3s via get.k3s.io creates a world readable /etc/rancher/k3s/k3s.yaml file, which appears to contain a plain text admin password.
The text was updated successfully, but these errors were encountered: