Nodelocal DNS Cache can not resolve /etc/hosts each node

Asking for help? Comment out what you need so we can get more information to help you!

Each /etc/hosts node have local domain xx.xx.xx.xx harbor.io. Before install Nodelocal DNS Cache, in another pod I can dig harbor.io and return ip in /etc/hosts .

dig harbor.io

; <<>> DiG 9.9.5-9+deb8u19-Debian <<>> harbor.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10551
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;harbor.io.                     IN      A

;; ANSWER SECTION:
harbor.io.              30      IN      A       xx.xx.xx.xx

;; Query time: 0 msec
;; SERVER: 10.96.0.10#53(10.96.0.10)
;; WHEN: Fri Sep 09 07:18:10 UTC 2022
;; MSG SIZE  rcvd: 63

When I run Nodelocal DNS Cache follow file https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml and replace follow:

kubedns = 10.96.0.10
domain = cluster.local
localdns = 169.254.0.10
sed -i "s/__PILLAR__LOCAL__DNS__/$localdns/g; s/__PILLAR__DNS__DOMAIN__/$domain/g; s/__PILLAR__DNS__SERVER__/$kubedns/g" nodelocaldns.yaml

then dig harbor.io return another ip address:

; <<>> DiG 9.9.5-9+deb8u19-Debian <<>> harbor.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34507
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;harbor.io.                     IN      A

;; ANSWER SECTION:
harbor.io.              30      IN      A       204.232.175.78

;; Query time: 481 msec
;; SERVER: 10.96.0.10#53(10.96.0.10)
;; WHEN: Fri Sep 09 07:15:15 UTC 2022
;; MSG SIZE  rcvd: 63

In another pod add config

dnsConfig:
    nameservers:
    - 169.254.0.10
    searches:
    - default.svc.cluster.local
    - svc.cluster.local
    - cluster.local
    options:
    - name: ndots
      value: '2'

Cluster information:

Kubernetes version: v1.23.7
Installation method: kubeadm
Host OS: Ubuntu 20.04 LTS
CNI and version: calico v3.23.1
CRI and version: docker://20.10.12