Welcome to Firefly
English
Firefly Docsss
Last Updated: 2026-09-29 15:48:06

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.sh

Delete the Node Object on the Server

sudo k3s kubectl get nodes
sudo k3s kubectl delete node sub11

Remove the Container

sudo docker rm -f k3s-agent

Clean 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/node

Delete the Node Object on the Server

sudo k3s kubectl delete node sub11

Server Uninstallation

Stop the Workloads

sudo K3S_DATA_DIR=/userdata/k3s /usr/local/bin/k3s-killall.sh

Remove 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.sh

Remove the Container

sudo docker rm -f k3s-server

Remove the Derived Network Interfaces

sudo ip link delete cni0
sudo ip link delete flannel.1

Clean Up the Rules

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/node

On this page