1. Add DNS to the host

1.1 CentOS

Edit the resolve.conf file directly.

1
2
3
4
/etc/resolv.conf 

nameserver 114.114.114.114
nameserver 8.8.8.8

1.2 Ubuntu

Since resolve.conf is automatically generated, you need to change resolved.conf to make it work.

1
2
3
4
5
vim /etc/systemd/resolved.conf

[Resolve]
DNS=114.114.114.114
DNS=8.8.8.8

Then restart the resolve service.

1
systemctl restart systemd-resolved.service

Finally, you can also confirm that the configuration is in effect.

1
systemd-resolve --status

2. Restart Nodelocaldns

When launching an external request in the Pod, the resolution logic is nodelocaldns -> DNS configured by the node -> return IP.

1
kubectl -n kube-system rollout restart ds nodelocaldns