say.farewell.cloud admin

K8s Learning: Step 99 — Remove k3s from VM

99 — Remove k3s from VM

Script: 99_remove_from_vm.sh · The nuclear option

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/config on laptop still points to the old cluster (won't work)
  • The /externaldata directory 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

ScenarioUse 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
← Back to homepage