Skip to content

Instantly share code, notes, and snippets.

@JhoLee
Last active March 2, 2023 00:53
Show Gist options
  • Save JhoLee/641a34e63505d29fa0cf3c2d17d1ea23 to your computer and use it in GitHub Desktop.
Save JhoLee/641a34e63505d29fa0cf3c2d17d1ea23 to your computer and use it in GitHub Desktop.
Reset K8S Node
echo -n "Really want to reset this node? (y/N): "
read -r check
if [[ "$check" = "y" ]]; then
echo "[INFO] Reset kubeadm"
kubeadm reset -f
echo "[INFO] Stop kubelet & docker service"
systemctl stop kubelet docker docker.socket
echo "[INFO] Remove K8S files"
rm -rvf /etc/kubernetes/*
rm -rvf /var/lib/kubelet/*
rm -rvf /var/lib/etcd/
echo "[INFO] Remove K8S network files"
rm -rf /var/run/calico/ /var/lib/calico/ /etc/cni/ /var/lib/cni/
ifconfig cni0 down
ifconfig flannel.1 down
ifconfig tunl0 down
ip link delete cni0
ip link delete flannel.1
ip link delete tunl0
ip link delete cilium_host
ip link delete cilium_vxlan
echo "[INFO] Restart docker"
systemctl restart docker
echo "[INFO] Done. You have to delete the node from your k8s with 'kubectl delete node $(hostname)'"
else
echo "[INFO] Cancel."
fi
@JhoLee
Copy link
Author

JhoLee commented Jul 28, 2022

Add ip link deletion for Cilium

  ip link delete cilium_host
  ip link delete cilium_vxlan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment