K3s, a lightweight Kubernetes distribution, has gained popularity for its ease of use and efficiency. However, circumstances may arise where you need to uninstall K3s from your system. Whether it’s for troubleshooting, upgrading, or transitioning to a different solution, properly removing K3s is essential. In this guide, we’ll walk you through the steps on how to remove K3s safely and effectively.
Step 1: Backup Your Data
Before beginning the uninstallation process, it’s crucial to back up any important data or configurations associated with K3s. This ensures that you can restore your system to its previous state if needed.
Step 2: Stop K3s Services
The first step in uninstalling K3s is to stop all running K3s services. You can do this by running the following command in your terminal:
sudo k3s-killall.sh
This command will terminate all K3s-related processes running on your system.
Step 3: Uninstall K3s
To remove K3s from your system, you’ll need to use the k3s-uninstall.sh script provided by the K3s installation. Run the following command in your terminal:
sudo /usr/local/bin/k3s-uninstall.sh
This script will uninstall K3s and remove all associated files and configurations from your system.
Step 4: Remove K3s Data Even
After uninstalling K3s, there may still be residual data left on your system. To ensure a clean uninstallation, you can manually remove any remaining K3s data by deleting the following directories:
- /etc/rancher/k3s
- /var/lib/rancher/k3s
- /etc/systemd/system/k3s.service
You can use the following commands to delete these directories:
sudo rm -rf /etc/rancher/k3s
sudo rm -rf /var/lib/rancher/k3s
suro rm /etc/systemd/system/k3s.service
Step 5: Verify Uninstallation
Once you’ve completed the uninstallation process, it’s essential to verify that K3s has been successfully removed from your system. You can do this by checking for any remaining K3s processes or files using the following commands:
ps aux | grep k3s ls /etc/rancher/k3s ls /var/lib/rancher/k3s
If no K3s-related processes or files are found, then K3s has been successfully uninstalled from your system.
Conclusion
Uninstalling K3s from your system doesn’t have to be a daunting task. By following the steps outlined in this guide, you can safely and effectively remove K3s and its associated files and configurations. Whether you’re troubleshooting issues or transitioning to a different Kubernetes solution, properly uninstalling K3s ensures a clean and smooth transition.
Share this content: