Is your feature request related to a problem? Please describe.
feature request
I mistakenly used the server curl (on the front-page) on all my raspberry pi's but now each one seems to be set up as a server. I thought it was just going to install k3s and then I'd delegate the installation as a server.
Describe the solution you'd like
I'd like a single command to remove k3s completely from my server. An uninstall script.
Describe alternatives you've considered
Currently I have to flash to whole SD card and then prepare my raspberrypi installation again (open ssh, set staticip, change password, etc) and then reinstall k3s
Additional context
I'm running this on raspberrypi.
Run /usr/local/bin/k3s-uninstall.sh
@marcstreeter after running curl -sfL https://get.k3s.io | sh - you will find a script called k3s-uninstall.sh which you can find in your /usr/local/bin, so if you want to completely remove k3s you can just run
/usr/local/bin/k3s-uninstall.sh
very nice. Many many thanks!
If you downloaded k3s manually and didn't get the uninstall script, here it is:
#!/bin/sh
set -x
systemctl stop k3s
systemctl disable k3s
systemctl daemon-reload
rm -f /etc/systemd/system/k3s.service
rm -f /usr/local/bin/k3s
if [ -L /usr/local/bin/kubectl ]; then
rm -f /usr/local/bin/kubectl
fi
if [ -L /usr/local/bin/crictl ]; then
rm -f /usr/local/bin/crictl
fi
if [ -e /sys/fs/cgroup/systemd/system.slice/k3s.service/cgroup.procs ]; then
kill -9 `cat /sys/fs/cgroup/systemd/system.slice/k3s.service/cgroup.procs`
fi
umount `cat /proc/self/mounts | awk '{print $2}' | grep '^/run/k3s'`
umount `cat /proc/self/mounts | awk '{print $2}' | grep '^/var/lib/rancher/k3s'`
rm -rf /var/lib/rancher/k3s
rm -rf /etc/rancher/k3s
rm -f /usr/local/bin/k3s-uninstall.sh
If you downloaded k3s manually and didn't get the uninstall script, here it is:
#!/bin/sh set -x systemctl stop k3s systemctl disable k3s systemctl daemon-reload rm -f /etc/systemd/system/k3s.service rm -f /usr/local/bin/k3s if [ -L /usr/local/bin/kubectl ]; then rm -f /usr/local/bin/kubectl fi if [ -L /usr/local/bin/crictl ]; then rm -f /usr/local/bin/crictl fi if [ -e /sys/fs/cgroup/systemd/system.slice/k3s.service/cgroup.procs ]; then kill -9 `cat /sys/fs/cgroup/systemd/system.slice/k3s.service/cgroup.procs` fi umount `cat /proc/self/mounts | awk '{print $2}' | grep '^/run/k3s'` umount `cat /proc/self/mounts | awk '{print $2}' | grep '^/var/lib/rancher/k3s'` rm -rf /var/lib/rancher/k3s rm -rf /etc/rancher/k3s rm -f /usr/local/bin/k3s-uninstall.sh
What about macos? for downloaded k3s manually, how can i uninstall k3s?
Run this on worker node: sudo /usr/local/bin/k3s-agent-uninstall.sh
I ended up with a lot of k3s related processes running after having run k3s-uninstall.sh.
With ps auxf spotted that kube-apiserver etc was running under containerd. Not knowing fully how to get rid of these remnants that i think associate with messing around with k3s, I did systemctl disable containerd and systemctl stop containerd and successfully saved myself plenty of RAM/CPU usage.
This stackoverflow answer helped me a lot: https://serverfault.com/questions/232762/linux-how-to-know-where-a-process-was-started-and-how-it-was-started/233250#233250?newreg=3bda84bbaaad4b21bb698841023bb006
Most helpful comment
Run /usr/local/bin/k3s-uninstall.sh