Skip to content

Instantly share code, notes, and snippets.

@dmagda
Created July 24, 2023 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmagda/bfebbcaadf4ee14bc536ba5107ed4c9c to your computer and use it in GitHub Desktop.
Save dmagda/bfebbcaadf4ee14bc536ba5107ed4c9c to your computer and use it in GitHub Desktop.
Uninstall Custom K3s Build
  1. Stop all the K3s processes:
    sudo kill $(ps aux | grep 'k3s' | awk '{print $2}')
  2. Create the k3s_uninstall.sh script with the following content and execute it:
    #!/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 -rf /etc/rancher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment