CoreDNS unnecessary recursion on shortnames

Cluster information:

Kubernetes version: v1.26.3
Cloud being used: bare-metal
Installation method: kubeadm
Host OS: Ubuntu 22.04.2
CNI and version: calico v3.25
CRI and version: containerd.io 1.6.18

Question:

Is there something smart I could/should do to get coredns to resolv shortnames faster? My guess is that it recurses unnecessarily when looking up shortnames causing the following time delay:

root@webone:/$ time getent hosts webone-svc                                                                                                                                                    
10.102.48.105   webone-svc.default.svc.cluster.local

real    0m3.667s
user    0m0.002s
sys     0m0.000s

While a fqdn is resolved in a much more timely fashion:

root@webone:/$ time getent hosts webone-svc.default.svc.cluster.local.                                                                                                                         
10.102.48.105   webone-svc.default.svc.cluster.local

real    0m0.002s
user    0m0.001s
sys     0m0.000s

This is due to the ndots setting / search paths.

As you observed you can use FQDN to avoid searching.

You can also use use pod dnsConfig field to lower ndots, YMMV on what the best setting is. Lowering it too low will result in immediately making absolute queries (like FQDN does) instead of searches.

There’s an example that sets the pod’s ndots here:

1 Like