Ubuntu 14.04 client failed to resolve k8s service name

7/29/2019

I have a K8S 1.14 cluster setup with CoreDNS 1.5.0 as default DNS server. My ubuntu 14.04 client failed to resolve service name when I got a response with TTL less than the minimun TTL value in SOA field(response with IPv6 result, no IPv6 address resolved).

I tried to use the same client code in Ubuntu 18.04 which can resolve the service name every time. I'm using python socket.getaddrinfo to resolve the service name, using socket.gethostbyname works around this issue since it only queries the A records.

This is the code i used to test

import socket
import time

while True:
    try:
        time.sleep(2)
        print socket.getaddrinfo("kubernetes", "443")
    except Exception as e:
        print e

The result of running this code is as followed:

[(2, 1, 6, '', ('10.233.0.1', 443)), (2, 2, 17, '', ('10.233.0.1', 443)), (2, 3, 0, '', ('10.233.0.1', 443))]

[Errno -5] No address associated with hostname

[Errno -5] No address associated with hostname

[(2, 1, 6, '', ('10.233.0.1', 443)), (2, 2, 17, '', ('10.233.0.1', 443)), (2, 3, 0, '', ('10.233.0.1', 443))]

[Errno -5] No address associated with hostname

[Errno -5] No address associated with hostname

When i update the default ttl to 30 seconds, I got more failures util I got the response with TTL 30

-- Hang Du
coredns
kubernetes

2 Answers

1/2/2020

Please upgrade your coredns to the latest, this issue is fixed in v1.5.1, here is the change log

-- xiez
Source: StackOverflow

7/31/2019

It seems this problem is related to dns caching.

Before dns caching was enabled in ubuntu 14:04:

[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[Errno -5] No address associated with hostname
[Errno -5] No address associated with hostname
[Errno -5] No address associated with hostname

After dns caching installation f.e. nscd:

apt-get install nscd
service nscd start

[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]
[(2, 1, 6, '', ('10.96.0.1', 443)), (2, 2, 17, '', ('10.96.0.1', 443)), (2, 3, 0, '', ('10.96.0.1', 443))]

You can verify your dns caching in /etc/nscd.conf

If i am correct - DNS isn't cached in Ubuntu < 17.04

In addition - according to official release timeline for ubuntu 14.04.6: End of Standard Support is April 2019 Hope this help.

-- Hanx
Source: StackOverflow