CoreDNS only works in one host in kubernete cluster

2/12/2020

I have a kubernetes with 3 nodes:

[root@ops001 ~]# kubectl get nodes
NAME            STATUS   ROLES    AGE    VERSION
azshara-k8s01   Ready    <none>   143d   v1.15.2
azshara-k8s02   Ready    <none>   143d   v1.15.2
azshara-k8s03   Ready    <none>   143d   v1.15.2

when after I am deployed some pods I found only one nodes azshara-k8s03 could resolve DNS, the other two nodes could not resolve DNS.this is my azshara-k8s03 host node /etc/resolv.conf:

options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
nameserver 100.100.2.136
nameserver 100.100.2.138

this is the other 2 node /etc/resolv.conf:

nameserver 114.114.114.114

should I keep the same ? what should I do to make the DNS works fine in 3 nodes?

-- Dolphin
kubernetes

2 Answers

2/14/2020

First step,your CoreDNS port are listening on port you specify,you can login Pod in other pod and try to using telnet command to make sure the DNS expose port is accesseable(current I am using alpine,centos using yum,ubuntu or debian using apt-get):

apk add busybox-extras
telnet <your coredns server ip> <your coredns listening port>

Second step: login pods on each host machine and make sure the port is accessable in each pod,if telnet port is not accessable,you should fix your cluser net first.

-- Dolphin
Source: StackOverflow

2/12/2020

did you try if 114.114.114.114 is actually reachable from your nodes? if not, change it to something that actually is ;-]

also check which resolv.conf your kublets actually use: it is often something else than /etc/resolv.conf: do ps ax |grep kubelet and check the value of --resolv-conf flag and see if the DNSes in that file work correctly.

update:

what names are failing to resolve on the 2 problematic nodes? are these public names or internal only? if they are internal only than 114.114.114 will not know about them. 100.100.2.136 and 100.100.2.138 are not reachable for me: are they your internal DNSes? if so try to just change /etc/resolv.conf on 2 nodes that don't work to be the same as on the one that works.

-- morgwai
Source: StackOverflow