How to undo kubectl delete node

2/20/2019

I have a k8s cluster on Azure created with asc-engine. It has 4 windows agent nodes.

Recently 2 of the nodes went into a not-ready state and remained there for over a day. In an attempt to correct the situation I did a "kubectl delete node" command on both of the not-ready nodes, thinking that they would simply be restarted in the same way that a pod that is part of a deployment is restarted.

No such luck. The nodes no longer appear in the "kubectl get nodes" list. The virtual machines that are backing the nodes are still there and still running. I tried restarting the VMs thinking that this might cause them to self register, but no luck.

How do I get the nodes back as part of the k8s cluster? Otherwise, how do I recover from this situation? Worse case I can simply throw away the entire cluster and recreate it, but I really would like to simply fix what I have.

-- AQuirky
azure
azure-aks
azure-kubernetes
kubectl
kubernetes

1 Answer

2/21/2019

You can delete the virtual machines and rerun your acs engine template, that should bring the nodes back (although, i didnt really test your exact scenario). Or you could simply create a new cluster, not that it takes a lot of time, since you just need to run your template.

There is no way of recovering from deletion of object in k8s. Pretty sure they are purged from etcd as soon as you delete them.

-- 4c74356b41
Source: StackOverflow