DNS lookup timeouts
Symptoms Outbound requests from pods can see a 5 second delay during DNS lookups. This is known to impact containers based off of the alpine image.
Root Cause https://www.weave.works/blog/racy-conntrack-and-dns-lookup-timeouts
Workaround Add the following to your impacted pod's manifest.
postStart:
exec:
command:
- /bin/sh
- -c
- "/bin/echo 'options single-request-reopen' >> /etc/resolv.conf"
What is single-request-reopen?
single-request-reopen (since glibc 2.9)
Sets RES_SNGLKUPREOP in _res.options. The resolver
uses the same socket for the A and AAAA requests. Some
hardware mistakenly sends back only one reply. When
that happens the client system will sit and wait for
the second reply. Turning this option on changes this
behavior so that if two requests from the same port are
not handled correctly it will close the socket and open
a new one before sending the second request.
FYI, I have not testing this personally -- this supposedly will not work for Alpine based containers since MUSL lib that Alpine uses does not support this option.
https://github.com/kubernetes/kubernetes/issues/62628#issuecomment-389341878
We had the same issue using alpine image. It's not a AKS problem, but a general kubernetes issue: See https://github.com/kubernetes/kubernetes/issues/56903
I would recommend to read this: https://blog.quentin-machu.fr/2018/06/24/5-15s-dns-lookups-on-kubernetes/
We changed our base image to jessie-slim and added this to the pod manifest.
dnsConfig:
options:
- name: single-request-reopen
more details : https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
I think it is a cleaner solution than adding a postStart hook.
I'm not sure what to think about this. Is the advice going to be: 'you can't run Alpine and need to customise DNS' if you expect proper DNS performance?
Could someone from Microsoft weigh in here?
This also works, and it works on alpine pods:
https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy service/networking/custom-dns.yaml apiVersion: v1 kind: Pod metadata: namespace: default name: dns-example spec: containers: - name: test image: nginx dnsPolicy: "None" dnsConfig: nameservers: - 1.2.3.4 searches: - ns1.svc.cluster.local - my.dns.search.suffix options: - name: ndots value: "2" - name: edns0
We have the same problem, will AKS rollout a solution for us? I don't see an elegant workaround so far.
@AXington Your solution reduces the delay from 5 seconds to 2.5 :), but still not fully work.
@juan-lee your workaround didn't work perfectly for the alpine based images, any better idea?
@juan-lee your workaround didn't work perfectly for the alpine based images, any better idea?
My understanding is that we've rolled the fix out during this week's release. You will have to upgrade your cluster to a newer version of k8s to get the changes.
Thanks very much, @juan-lee, I will let you know how does it work. Br, Tim
@juan-lee The 1.11.4 solves this problem, thanks for your help.
Br, Tim
I checked official change log can't find specific change that addresses this bug in the change log, but amazingly the upgrade seems to fix this issue for our AKS cluster. I hope it will not come back on next version bump.
I checked official change log can't find specific change that addresses this bug in the change log, but amazingly the upgrade seems to fix this issue for our AKS cluster. I hope it will not come back on next version bump.
The fix isn't in k8s, but rather a kernel patch that is now default for new agent nodes. The reason you're seeing the problem go away with an upgrade is because your old agent nodes are replaced with ones that have the new kernel.
Ok I see, thanks for explanation@juan-lee
@juan-lee is the fix only present in the new 'MobyImage' that you have to register for, or is it present in all 1.11.4 images?
Hi people! As it stands today, all new VMs (through new cluster, scale, or upgrade) have the kernel fix '"netfilter: nf_conntrack: resolve clash for matching conntracks" fixes the 1st race (accepted).` described in https://www.weave.works/blog/racy-conntrack-and-dns-lookup-timeouts
Thanks
@weinong any info on when the second race will be addressed?
I just hit this, and single-request-reopen does seem to make it go away! This is on a recent fresh 1.13.5 aks cluster. Not sure why the DNS server gives the wrong answer to begin with. Is this a coredns issue ?
Thanks @juan-lee for the work-around 👍
Hi @weinong .. I deployed a cluster a few days back, and still hitting this. So I think it's still not fixed. Is there any update when a fix is expected to land. Also taking a chance and pinging @jnoller
Hi people. Is this issue fixed with kubernetes 1.13.5? I wanted to upgrade my AKS cluster to the said version, but I am using multiple deployments with alpine-based images.
Still seeing the issue with kernel-version 4.15.0-1063-azure