1. Home
  2. Why Is DNS Resolution Failing in My Kubernetes Containers?

Why Is DNS Resolution Failing in My Kubernetes Containers?

 If the cluster is running Bright 9.2 and using Ubuntu 22.04 for the nodes that are part of the Kubernetes cluster, then you may notice that DNS resolution inside Kubernetes containers is failing.

For example:

# kubectl exec -i -t dnsutils — nslookup www.google.com
Server: 10.150.255.254
Address: 10.150.255.254#53

Non-authoritative answer:
Name: www.google.com.DOMAINS
Address: 18.239.83.89
Name: www.google.com.DOMAINS
Address: 18.239.83.114
Name: www.google.com.DOMAINS
Address: 18.239.83.106
Name: www.google.com.DOMAINS
Address: 18.239.83.3

This behavior is due to an upstream issue with Ubuntu 22.04.  The /etc/network/if-up.d/resolved file will need to be changed on all Ubuntu 22.04 nodes that are part of the Kubernetes cluster as follows:

# diff /etc/network/if-up.d/resolved.orig /etc/network/if-up.d/resolved
47c47
< "$DNS"="$NEW_DNS"
---
> $DNS="$NEW_DNS"
51c51
< "$DOMAINS"="$NEW_DOMAINS"
---
> $DOMAINS="$NEW_DOMAINS"

…where resolved.orig is the original resolved file that comes with Ubuntu 22.04 and resolved is the corrected file.

The nodes will then need to be rebooted.

Afterward, DNS resolution within Kubernetes containers should work.

Updated on October 11, 2023