To completely remove Rancher RKE2 (Rancher Kubernetes Engine 2) from a Linux system (Ubuntu, CentOS, Rocky, etc.), follow these steps carefully.
Step 1: Stop the RKE2 Services
sudo systemctl status rke2-server
sudo systemctl stop rke2-server
sudo systemctl disable rke2-server
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
Step 2: Run the Uninstall Script
RKE2 includes uninstall scripts by default.
sudo /usr/local/bin/rke2-uninstall.sh
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
Step 3: Remove Any Remaining Files (Optional Cleanup)
After running the uninstall script, some leftover files or directories may remain.
You can clean them up manually:
sudo rm -rf /etc/rancher/rke2
sudo rm -rf /var/lib/rancher
sudo rm -rf /var/lib/kubelet
sudo rm -rf /etc/systemd/system/rke2*
sudo rm -rf /usr/local/lib/systemd/system/rke2*
sudo rm -rf /usr/local/bin/rke2*
sudo rm -rf /var/lib/cni/
sudo rm -rf /etc/cni/
sudo rm -rf /var/lib/containerd/
sudo rm -rf /run/k3s/
sudo rm -rf /var/lib/rancher-data/
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
Step 4: Verify Removal
Check that the service is gone:
systemctl status rke2-server
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
Optional: Remove RKE2 Configuration and Binaries (If Needed)
If you installed RKE2 using a tarball or custom install path, ensure binaries are removed:
sudo rm -f /usr/local/bin/rke2*
sudo rm -f /usr/bin/rke2*
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Optional: Remove CNI & Container Runtime
If you want a full system cleanup (removes network config and containerd data):
sudo rm -rf /var/lib/containerd
sudo rm -rf /etc/cni
sudo rm -rf /var/lib/cni
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
Step 5: Reboot (Recommended)
After cleanup:
sudo reboot
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
Remove Node from Cluster
Identify the worker node name
kubectl get nodes
Always drain the node first before deletion to safely evict pods
kubectl drain #####CONTROL_NODE_NAME##### --ignore-daemonsets --delete-emptydir-data
kubectl delete node #####CONTROL_NODE_NAME#####
◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇
#fypシ #k3s #kubernetes #github