K8s Learning: Step 99 — Remove k3s from VM
99 — Remove k3s from VM
Completely uninstalls k3s from the VM — removes the cluster, all deployments, all services, all secrets (including TLS certs), all container images.
⚠️ This is destructive. After running this:
- Your app is offline
- All Kubernetes resources are deleted
- TLS certificates are gone (cert-manager will re-obtain on next deploy)
- Your
~/.kube/configon laptop still points to the old cluster (won't work)- The
/externaldatadirectory is not deleted (hostPath persists on host)
The Command
ssh $K3S_SSH_USER@$K3S_SSH_HOSTNAME \
'sudo /usr/local/bin/k3s-uninstall.sh' || true
k3s ships with its own uninstall script. It stops the service, removes binaries and data, cleans up iptables and network interfaces, removes the systemd service, kills all containers. The || true prevents failure if k3s isn't installed.
When to Use This
| Scenario | Use this? |
|---|---|
| Full redeploy (broken cluster, new k3s version) | ✅ Yes |
| Decommissioning the cluster entirely | ✅ Yes |
| Cluster in a bad state, easier to start fresh | ✅ Yes |
| Normal app code update | ❌ No — just run steps 05 + 06 |
| Changed deploy config only | ❌ No — just run step 06 |