-1

I have a coredns pod running in kube-system namespace. I need to restart the coredns pod without downtime. I am aware that we can do delete coredns pod using below command and new coredns pod will spin up automatically. kubectl delete pods -n kube-system -l k8s-app=kube-dns

But it is creating downtime. So I am expecting to do a restart of this coredns pod without downtime.

It would be really helpful when someone helps me on this. Thanks in advance!

anonymous user
  • 257
  • 5
  • 23
  • 1
    wondering, are you not having replicas for that pod running to failover ? – P.... Jun 17 '22 at 15:23
  • Same here, scale the coredns deployment to more than one pod, and then you can delete the old pod instance and scale down....but you should have more than 1 replica – Hackerman Jun 17 '22 at 15:24
  • @Hackerman As I am quite new to this containerization, can you show an example how we can modify coredns deployment to have replica more than 1? – anonymous user Jun 17 '22 at 15:49
  • `kubectl scale --help` is your friend. – P.... Jun 17 '22 at 15:53

2 Answers2

1

Normally, the result of this command kubectl get deployment coredns --namespace kube-system --output jsonpath='{.spec.strategy.rollingUpdate.maxUnavailable}' will return 1; means for deployment of 2 pods (typical coredns setup), pod will be replace 1 at a time, leaving the other one serving request. In this case, you can run kubectl rollout restart deployment coredns --namespace kube-system to restart without downtime, no explicitly delete or hike coredns pod count required.

gohm'c
  • 13,492
  • 1
  • 9
  • 16
0

Why do you need to restart coredns? If you need to reload coredns configmap, the best practice is to reload coredns when configmap is changed.

The coredns will reload itself after a period of 30 to 45 secs as you have specified the 'reload' configuration in the configMap. https://coredns.io/plugins/reload/

https://stackoverflow.com/a/75757002/6059840

wow qing
  • 352
  • 4
  • 9
  • If you think another question Stack Overflow answers this one as well, don't just post a link to that answer (never post link-only answers at all actually). Instead, [flag it as a duplicate](/help/duplicates), thus associating this question with the target, keeping knowledge centralised. – Adriaan Aug 29 '23 at 07:36