Skip to content

Instantly share code, notes, and snippets.

@bachmanity1
Created February 24, 2026 05:51
Show Gist options
  • Select an option

  • Save bachmanity1/2f1297cd90b65b4a227f741e39954684 to your computer and use it in GitHub Desktop.

Select an option

Save bachmanity1/2f1297cd90b65b4a227f741e39954684 to your computer and use it in GitHub Desktop.
Uninstall Kubernetes from node
#!/bin/bash
set -e
echo "[1/6] Resetting kubeadm"
kubeadm reset -f || true
echo "[2/6] Stopping services"
systemctl stop kubelet || true
systemctl disable kubelet || true
systemctl stop containerd || true
systemctl disable containerd || true
echo "[3/6] Cleaning up directories"
rm -rf /etc/kubernetes /var/lib/kubelet /var/lib/etcd /etc/cni/net.d /var/lib/cni
rm -f /etc/kubernetes/bootstrap-kubelet.conf
echo "[4/6] Flushing iptables"
iptables -F
iptables -t nat -F
iptables -t mangle -F
ipvsadm --clear 2>/dev/null || true
echo "[5/6] Removing packages"
dnf remove -y kubelet kubeadm kubectl containerd.io || true
echo "[6/6] Removing repo"
rm -f /etc/yum.repos.d/kubernetes.repo
echo "✅ Kubernetes fully removed from this node."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment