Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Kubernetes CoreDNS to reload its Config Map after a change?

I'm running Kubernetes 1.11, and trying to configure the Kubernetes cluster to check a local name server first. I read the instructions on the Kubernetes site for customizing CoreDNS, and used the Dashboard to edit the system ConfigMap for CoreDNS. The resulting corefile value is:

.:53 {
    errors
    health
    kubernetes cluster.local in-addr.arpa ip6.arpa {
       pods insecure
       upstream    192.168.1.3 209.18.47.61
       fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    proxy . /etc/resolv.conf
    cache 30
    reload
}

You can see the local address as the first upstream name server. My problem is that this doesn't seem to have made any impact. I have a container running with ping & nslookup, and neither will resolve names from the local name server.

I've worked around the problem for the moment by specifying the name server configuration in a few pod specifications that need it, but I don't like the workaround.

How do I force CoreDNS to update based on the changed ConfigMap? I can see that it is a Deployment in kube-system namespace, but I haven't found any docs on how to get it to reload or otherwise respond to a changed configuration.

like image 320
E. Wittle Avatar asked Nov 27 '18 11:11

E. Wittle


2 Answers

One way to apply Configmap changes would be to redeploy CoreDNS pods:

kubectl rollout restart -n kube-system deployment/coredns
like image 69
Viliam Pucik Avatar answered Sep 28 '22 21:09

Viliam Pucik


You can edit it in command line:

kubectl edit cm coredns -n kube-system

Save it and exit, which should reload it.

If it will not reload, as Emruz Hossain advised delete coredns:

kubectl get pods -n kube-system -oname |grep coredns |xargs kubectl delete -n kube-system

like image 39
Crou Avatar answered Sep 28 '22 19:09

Crou