Last active
March 2, 2023 00:53
-
-
Save JhoLee/641a34e63505d29fa0cf3c2d17d1ea23 to your computer and use it in GitHub Desktop.
Reset K8S Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add ip link deletion for Cilium