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: 1.6.18


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                                                                                                                                              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.                                                                                                                   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