Flush CoreDNS Cache on Kubernetes Cluster
Asked Answered
O

3

16

How to flush CoreDNS Cache on kubernetes cluster?

I know it can be done by deleting the CoreDNS pods, but is there a proper way to to the cache flush ?

Octosyllable answered 26/2, 2019 at 4:3 Comment(0)
C
18

The best way, as you said, would be restarting coredns pods. This can be done easily, by scaling the coredns deployment to "0" and then, scale it back to the desired number. Like in the sample command below:

kubectl scale deployment.apps/coredns -n kube-system --replicas=0
kubectl scale deployment.apps/coredns -n kube-system --replicas=2

without timout:

kubectl rollout restart deployment coredns -n kube-system

Thanks @Nick for comment

Cristobalcristobalite answered 26/2, 2019 at 11:1 Comment(0)
M
16

@coollinuxoid's answer is not suitable for production environment, it will have temporary downtime because the commands will terminate all pods at the same time. Instead, you should use kubernetes deployment's rolling update mechanism by setting an environment variable to avoid the downtime with command:

kubectl -n kube-system set env deployment.apps/coredns FOO="BAR"
Manicotti answered 30/8, 2019 at 3:44 Comment(2)
And kubectl -n kube-system set env deployment.apps/coredns FOO- to get rid of the env variable again...Codie
I think you can avoid setting an environment variable altogether: kubectl rollout restart deployment coredns -n kube-systemDocument
C
-8

execute this in each rabbitmq pod to remove mnesia, then restart pods

rm -rf /bitnami/rabbitmq/mnesia
Collins answered 7/12, 2020 at 5:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.