我查看日志,发现一直在刷一下错误:
Nov 14 11:07:31 node02 kubelet[1543]: E1114 11:07:31.956476 1543 dns.go:157] "Nameserver limits exceeded" err="Nameserver limits were exceeded, some nameservers have been omitted, the applied nameserver line is: 114.114.114.114 114.114.114.114 114.114.114.114"
我是Ubuntu 22.04.3 LTS。
cat /run/systemd/resolve/resolv.conf | grep -v '#'
nameserver 114.114.114.114
nameserver 114.114.114.114
nameserver 114.114.114.114
nameserver 114.114.114.114
search .
我应该怎么解决?
也可能是网卡配置多个了
sudo cat /etc/netplan/01-netcfg.yaml
将nameservers设置成
[]
:ens192: addresses: - 10.233.164.101/24 nameservers: addresses: []
重启路由
sudo netplan apply
简单的说,就是
/etc/resolv.conf
中有太多的条目,默认最大是3
个。代码
kubernetes/pkg/apis/core/validation /validation.go
:const ( // Limits on various DNS parameters. These are derived from // restrictions in Linux libc name resolution handling. // Max number of DNS name servers. MaxDNSNameservers = 3 // Max number of domains in search path. MaxDNSSearchPaths = 6 // Max number of characters in search path. MaxDNSSearchListChars = 256 )
这是一个已知的问题:
而且,
/run/systemd/resolve/resolv.conf
将在每次k8s重启后自动重新创建。所以。你可以通过
--resolv-conf
指定/etc/resolv.conf
,例如,在/var/lib/kubelet/kubeadm-flags.env
中追加:KUBELET_KUBEADM_ARGS="--container-runtime=remote --container-runtime-endpoint=unix:///var/run/cri-dockerd.sock --resolv-conf=/etc/resolv.conf"
然后重启:
systemctl restart kubelet
错误就不见了。
你的答案