i deleted the core dns using kubectl delete deployment coredns -n kube-system

3k Views Asked by At

I accidentally deleted the core DNS using kubectl delete deployment coredns -n kube-system how to do I get the coredns pods to run again....

I recreated the coredns using kubectl create deployment coredns -n kube-system --image=k8s.gcr.io/coredns:1.7.0 but nslookup is failing is there any way to correct it. root@km1:~# kubectl get pods --all-namespaces -o wide
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE   IP              NODE   NOMINATED NODE   READINESS GATES
default       dnsutils                                   2/2     Running   9          22h   10.10.159.72    kw1    <none>           <none>
kube-system   calico-kube-controllers-5c6f6b67db-mp9jg   1/1     Running   2          26h   10.10.132.201   km1    <none>           <none>
kube-system   calico-node-fscgw                          1/1     Running   2          26h   192.168.0.215   km1    <none>           <none>
kube-system   calico-node-m78kx                          1/1     Running   1          25h   192.168.0.204   kw1    <none>           <none>
kube-system   coredns-5646d5bb85-77pxl                   1/1     Running   0          12m   10.10.159.74    kw1    <none>           <none>
kube-system   etcd-km1                                   1/1     Running   2          26h   192.168.0.215   km1    <none>           <none>
kube-system   kube-apiserver-km1                         1/1     Running   2          26h   192.168.0.215   km1    <none>           <none>
kube-system   kube-controller-manager-km1                1/1     Running   3          26h   192.168.0.215   km1    <none>           <none>
kube-system   kube-proxy-h5pz5                           1/1     Running   1          25h   192.168.0.204   kw1    <none>           <none>
kube-system   kube-proxy-qdp4w                           1/1     Running   2          26h   192.168.0.215   km1    <none>           <none>
kube-system   kube-scheduler-km1                         1/1     Running   3          26h   192.168.0.215   km1    <none>           <none>

1

There are 1 best solutions below

0
On

Official coredns repo on github provides deploy.sh script that generates coredns yaml file. Checkout this link.

All you need to do is to clone the repo, go to deployment/kubernetes directory and run:

$ ./deploy.sh | kubectl apply -f -