K3s Uninstallation
This chapter describes how to uninstall the Server and the Agent. The steps correspond to the deployment methods described in K3s Deployment:
- Local deployment: K3s runs as a systemd service. Both the online and offline deployments are local deployments and are uninstalled in the same way.
- Docker deployment: K3s runs as a Docker container. After removing the container, also clean up the leftover data on the host.
Agent Uninstallation
Run the Uninstall Script
sudo K3S_DATA_DIR=/userdata/k3s /usr/local/bin/k3s-agent-uninstall.shDelete the Node Object on the Server
sudo k3s kubectl get nodes
sudo k3s kubectl delete node sub11Remove the Container
sudo docker rm -f k3s-agentClean Up the Network and Rules
sudo ip link delete cni0
sudo ip link delete flannel.1
sudo iptables-save | grep -v KUBE- | grep -v CNI- | grep -iv flannel | sudo iptables-restore
Remove the Data
sudo rm -rf /userdata/k3s /etc/rancher/k3s /etc/rancher/nodeDelete the Node Object on the Server
sudo k3s kubectl delete node sub11Server Uninstallation
Stop the Workloads
sudo K3S_DATA_DIR=/userdata/k3s /usr/local/bin/k3s-killall.shRemove the Derived Network Interfaces
ip -o link show | grep -E 'cni0|flannel'Run the Uninstall Script
sudo K3S_DATA_DIR=/userdata/k3s /usr/local/bin/k3s-uninstall.shRemove the Container
sudo docker rm -f k3s-serverRemove the Derived Network Interfaces
sudo ip link delete cni0
sudo ip link delete flannel.1Clean Up the Rules
sudo iptables-save | grep -v KUBE- | grep -v CNI- | grep -iv flannel | sudo iptables-restoreRemove the Data
sudo rm -rf /userdata/k3s /etc/rancher/k3s /etc/rancher/node
