This message was deleted.
# k3s
a
This message was deleted.
b
I've never run it with sudo or k3s...? Ensure /usr/local/bin is in your $PATH, get your k3s.yaml, copy, into you kubecofig then it's just
kubectl get nodes
b
This is a basic shell issue. If you struggle with this type of stuff and just want to try out k3s in a way you feel comfortable, set this in your environment before the install
Copy code
export INSTALL_K3S_BIN_DIR=/usr/bin
k3s-install
b
Or, set permissions on k3s.yaml (can do during install) and run for example;
Copy code
@kermit:~> which kubectl
/usr/local/bin/kubectl

@kermit:~> kubectl --kubeconfig=/etc/rancher/k3s/k3s.yaml get nodes
NAME     STATUS   ROLES                  AGE   VERSION
kermit   Ready    control-plane,master   48d   v1.26.9+k3s1
b
my suggestion is assuming you are installing k3s on a vm or something
s
@bored-farmer-36655 Thanks a lot, i changed k3s.yml permissions to 644 now my non-root user can perform a few administrative tasks
🙌 1
l
Just use kubectl directly … it works fine.
s
@late-needle-80860 no it wasn't, this is why i was asking weird things. so far looks like i missed something on initial k3s setup, since my k3s.yml has too restrictive permissions. i didn't faced that on other k8s implementations, kind and minikube for instance. @bored-farmer-36655 solved my problem, but i must understand the security implications of this.
b
no it wasn't, this is why i was asking weird things
Let me just break it down.
PATH
is how your shell searches for binaries. when you are running as your unprivileged user,
PATH
must have
/usr/bin/local
in it. You can see the difference with the following commands:
Copy code
echo $PATH
sudo $SHELL -c 'echo $PATH'
🎯 2
Honestly, it's easier if you just become the root user with
sudo -i
, which will set up the full shell for you, and likely have PATH configured as you need.
s
thanks for helping me out on how to get this, but as i told before the command was working only with sudo. my regular user do have
/usr/local/bin
in the path, this is why the error is very strange.
b
I know man, I'm trying to break it down. The issue is that sudo is not setting up the user to find that binary. get it?
that's why giving it the full path works
so far looks like i missed something on initial k3s setup, since my k3s.yml has too restrictive permissions.
You didn't do anything wrong. The permissions should be restrictive. I suggest at least 600. 644 is dangerous. All you need to do is look up the instructions for your distribution for making sure
/usr/local/bin
is always in PATH. Or you could use the environment variable I gave you above, which will install your binaries into
/usr/bin
which is guaranteed to be in all PATHs, no config or insecure permissions needed
I have tried k3s in some of the stranger immutable distros. Seriously, just use
Copy code
INSTALL_K3S_BIN_DIR=/usr/bin
when you are installing
also, in case you are doing this on your laptop and not using a VM, please consider rancher-desktop. it's more user friendly
🎯 1
s
so i should reset the permissions to 600 and go back to sudo whenever i want to do something directly from the box i am provisioning. and i did a faulty installation due the lack of the
INSTALL_K3S_BIN_DIR
. tonight i'll undo what i did on that vm and try again.
b
Good luck!
👍 1