超出 K8s coredns 和 flannel 名称服务器限制

K8s coredns and flannel nameserver limit exceeded

我一直在尝试在单个节点中设置 k8s,一切都安装得很好。但是当我检查我的 kube-system pods、

的状态时

CNI -> flannel pod crashed, 原因 -> 超出名称服务器限制,省略了一些名称服务器,应用的名称服务器行是:x.x.x.x x.x.x.x x.x.x.x

CoreDNS pods 状态为 ContainerCreating.

在我的办公室中,当前服务器已配置为具有静态 ip,当我检查时 /etc/resolv.conf

这是输出

# Generated by NetworkManager
search ORGDOMAIN.BIZ
nameserver 192.168.1.12
nameserver 192.168.2.137
nameserver 192.168.2.136
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver 192.168.1.10
nameserver 192.168.1.11

我找不到根本原因,我应该看什么?

简而言之,您在 /etc/resolv.conf 中的条目太多了。

这是一个known issue:

Some Linux distributions (e.g. Ubuntu), use a local DNS resolver by default (systemd-resolved). Systemd-resolved moves and replaces /etc/resolv.conf with a stub file that can cause a fatal forwarding loop when resolving names in upstream servers. This can be fixed manually by using kubelet’s --resolv-conf flag to point to the correct resolv.conf (With systemd-resolved, this is /run/systemd/resolve/resolv.conf). kubeadm (>= 1.11) automatically detects systemd-resolved, and adjusts the kubelet flags accordingly.

还有

Linux’s libc is impossibly stuck (see this bug from 2005) with limits of just 3 DNS nameserver records and 6 DNS search records. Kubernetes needs to consume 1 nameserver record and 3 search records. This means that if a local installation already uses 3 nameservers or uses more than 3 searches, some of those settings will be lost. As a partial workaround, the node can run dnsmasq which will provide more nameserver entries, but not more search entries. You can also use kubelet’s --resolv-conf flag.

If you are using Alpine version 3.3 or earlier as your base image, DNS may not work properly owing to a known issue with Alpine. Check here for more information.

您可以在 Kubernetes 代码中更改它,但我不确定功能。因为它被设置为该值。

代码可以定位here

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
)