corefile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.:53 {
        hosts {
          172.18.171.110  host1
          172.18.203.237  host2
          172.18.203.240  test.testdomain.cn
          cache 60
          reload 1m
          # 一定要加下面语句
          fallthrough
        }
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           upstream
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
  # test.io将由内部DNS解析
  test.io:53 {
    errors
    cache 30
    reload
    forward . 173.18.171.109
  }

注意点:

  • 不要绑定已存在的域名的A记录,比如上面的配置文件中,test.io将由173.18.171.109外部的DNS解析,则不能在hosts字段中出现以test.io域的主机名。例如hostname.test.io。这样,CoreDNS将始终交由外部DNS解析

  • 有些版本的CoreDNS修改corefile后重载会报错,需要手动删除掉老的Pod