1

我在本地网络中的某个树莓派 4 上运行 k3s 集群。我在主节点上有一个 DNS 服务器 (dnsmasq)。我希望我的集群的 pod 通过 coredns 使用该 DNS 服务器。但是,当我从 pod 中 ping 一个地址时,我总是通过谷歌 DNS 服务器并超越我的本地 DNS 规则。

apiVersion: v1
kind: ConfigMap
data:
  Corefile: |
    .:53 {
        errors
        health
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream
          fallthrough in-addr.arpa ip6.arpa
        }
        hosts /etc/coredns/NodeHosts {
          reload 1s
          fallthrough
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }

这是我的 coredns 配置。如您所见,有forward . /etc/resolv.conf

我的 /etc/resolv.conf

domain home
nameserver 127.0.0.1

有什么建议么 ?

4

3 回答 3

2

谢谢大家,我把我的 coredns 改成

kind: ConfigMap
metadata:
  annotations:
  name: coredns
  namespace: kube-system
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream
          fallthrough in-addr.arpa ip6.arpa
        }
        hosts /etc/coredns/NodeHosts {
          reload 1s
          fallthrough
        }
        prometheus :9153
        forward . <master node ip>
        cache 30
        loop
        reload
        loadbalance
    }
  NodeHosts: |
    <master node ip> master
    <slave node ip> slave

它奏效了!

于 2020-09-29T21:01:07.797 回答
1
于 2020-09-28T10:33:15.620 回答
0

您可以尝试仅转发到运行 DNS 服务器的主节点的真实 IP。这将是集群中其他节点可以使用的 IP。因此,它不是 /etc/resolv.conf,而是类似于:

forward . <master node ip>

于 2020-09-27T06:10:20.400 回答