使用 Kubeadm 部署的 CoreDNS 和 Ubuntu 18.04 集群的 Kubernetes DNS 解析问题

问题描述

我在 OVH 裸机服务器上部署了一个 Kubernetes 集群。集群使用 Kubeadm 部署,操作系统为 Ubuntu 18.04.5 LTS。 Calico 用作 CNI,我的 POD 出现间歇性 DNS 解析问题。

这里是 pod 中 DNS 解析的输出

bash-5.0# nslookup s3.amazonaws.com
Server:     10.96.0.10
Address:    10.96.0.10:53

Non-authoritative answer:
Name:   s3.amazonaws.com
Address: 52.217.88.54

Non-authoritative answer:

bash-5.0# nslookup s3.amazonaws.com
Server:     10.96.0.10
Address:    10.96.0.10:53


Name:   s3.amazonaws.com
Address: 52.217.88.54

bash-5.0# nslookup s3.amazonaws.com
;; connection timed out; no servers Could be reached

bash-5.0# nslookup s3.amazonaws.com
;; connection timed out; no servers Could be reached

bash-5.0# nslookup s3.amazonaws.com
;; connection timed out; no servers Could be reached

bash-5.0# nslookup s3.amazonaws.com
Server:     10.96.0.10
Address:    10.96.0.10:53

Non-authoritative answer:

Non-authoritative answer:
Name:   s3.amazonaws.com
Address: 52.217.102.142

我知道 Ubuntu 和 kubeadm 集群存在一些问题,但任何评论或答案都无法解决我的问题。最初,我觉得这是因为我的 /etc/resolv.conf 文件中的 127.0.0.1 名称服务器条目。如果我更新文件,它会被 /run/systemd/resolve/resolv.conf 文件更新,我已经停止了 systemd-resolved.service 并将 DNS 服务器更改为 google DNS。即使在那之后,我也没有看到任何改进。如果我更改了 pod 中的 /etc/resolv.conf 文件,使其按预期工作。

我还删除files 文件中的 nsswitch.conf 条目以直接检查 DNS 服务器作为故障排除步骤,它在更改后很快就起作用了,新 pod 再次出现问题。

这里是主机入口

cat /etc/nsswitch.conf | grep hosts
hosts:          dns

由于断断续续的连接,我可以确认没有防火墙端口问题,我对这个问题一无所知。任何人都可以帮我解决这个问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)