k8s添加自定义DNS解析

1、需要要添加的自定义解析

10.0.21.22 rocketmq-brokeras
10.0.21.21 rocketmq-brokerbs
10.0.21.20 rocketmq-brokera
10.0.21.25 rocketmq-brokerb

ping rocketmq-brokeras, 解析过程抓包主机会根据/etc/resolv.conf 中search配置拼接完成域名,发送到dns解析,抓包显示如下:

11:17:17.744804 IP (tos 0x0, ttl 64, id 25467, offset 0, flags [DF], proto UDP (17), length 90)
    172.31.24.41.54205 > 172.16.0.10.53: [bad udp cksum 0x70ba -> 0x3cc5!] 49243+ A? rocketmq-brokeras.test.cluster.local. (62)
11:17:17.744936 IP (tos 0x0, ttl 64, id 25468, offset 0, flags [DF], proto UDP (17), length 90)
    172.31.24.41.54205 > 172.16.0.10.53: [bad udp cksum 0x70ba -> 0x37c5!] 50496+ AAAA? rocketmq-brokeras.test.svc.cluster.local. (62)
11:17:17.745528 IP (tos 0x0, ttl 62, id 15516, offset 0, flags [DF], proto UDP (17), length 183)
    172.16.0.10.53 > 172.31.24.41.54205: [udp sum ok] 50496 NXDomain*- q: AAAA? rocketmq-brokeras.test.svc.cluster.local. 0/1/0 ns: cluster.local. SOA ns.dns.cluster.local. hostmaster.cluster.local. 1690341292 7200 1800 86400 30 (155)
11:17:17.745551 IP (tos 0x0, ttl 62, id 15517, offset 0, flags [DF], proto UDP (17), length 183)
    172.16.0.10.53 > 172.31.24.41.54205: [udp sum ok] 49243 NXDomain*- q: A? rocketmq-brokeras.test.svc.cluster.local. 0/1/0 ns: cluster.local. SOA ns.dns.cluster.local. hostmaster.cluster.local. 1690341292 7200 1800 86400 30 (155)
11:17:17.745602 IP (tos 0x0, ttl 64, id 25469, offset 0, flags [DF], proto UDP (17), length 81)
    172.31.24.41.41389 > 172.16.0.10.53: [bad udp cksum 0x70b1 -> 0x1254!] 53358+ A? rocketmq-brokeras.svc.cluster.local. (53)
11:17:17.745685 IP (tos 0x0, ttl 64, id 25470, offset 0, flags [DF], proto UDP (17), length 81)
    172.31.24.41.41389 > 172.16.0.10.53: [bad udp cksum 0x70b1 -> 0xf48c!] 54069+ AAAA? rocketmq-brokeras.svc.cluster.local. (53)
11:17:17.746203 IP (tos 0x0, ttl 63, id 57452, offset 0, flags [DF], proto UDP (17), length 174)
    172.16.0.10.53 > 172.31.24.41.41389: [bad udp cksum 0x710e -> 0xaf98!] 53358 NXDomain*- q: A? rocketmq-brokeras.svc.cluster.local. 0/1/0 ns: cluster.local. SOA ns.dns.cluster.local. hostmaster.cluster.local. 1690341280 7200 1800 86400 30 (146)
11:17:17.746333 IP (tos 0x0, ttl 63, id 57453, offset 0, flags [DF], proto UDP (17), length 174)
    172.16.0.10.53 > 172.31.24.41.41389: [bad udp cksum 0x710e -> 0x91d1!] 54069 NXDomain*- q: AAAA? rocketmq-brokeras.svc.cluster.local. 0/1/0 ns: cluster.local. SOA ns.dns.cluster.local. hostmaster.cluster.local. 1690341280 7200 1800 86400 30 (146)
11:17:17.746382 IP (tos 0x0, ttl 64, id 25471, offset 0, flags [DF], proto UDP (17), length 77)
    172.31.24.41.35005 > 172.16.0.10.53: [bad udp cksum 0x70ad -> 0xb343!] 49741+ A? rocketmq-brokeras.cluster.local. (49)
11:17:17.746443 IP (tos 0x0, ttl 64, id 25472, offset 0, flags [DF], proto UDP (17), length 77)
    172.31.24.41.35005 > 172.16.0.10.53: [bad udp cksum 0x70ad -> 0x95e0!] 50352+ AAAA? rocketmq-brokeras.cluster.local. (49)
11:17:17.747094 IP (tos 0x0, ttl 62, id 15518, offset 0, flags [DF], proto UDP (17), length 124)
    172.16.0.10.53 > 172.31.24.41.35005: [udp sum ok] 49741*- q: A? rocketmq-brokeras.cluster.local. 1/0/0 rocketmq-brokeras.cluster.local. A 10.0.21.22 (96)
11:17:17.747117 IP (tos 0x0, ttl 62, id 15519, offset 0, flags [DF], proto UDP (17), length 170)
    172.16.0.10.53 > 172.31.24.41.35005: [udp sum ok] 50352 NXDomain*- q: AAAA? rocketmq-brokeras.cluster.local. 0/1/0 ns: cluster.local. SOA ns.dns.cluster.local. hostmaster.cluster.local. 1690341292 7200 1800 86400 30 (142)

2、coredns调整

添加hosts配置段, rocketmq-brokeras域名对应配置到configmap中添加.cluster.local.
不然会在coredns解析超时后,通过其他流程解析造成解析慢的问题

apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health {
           lameduck 5s
        }
        ready
        hosts  {
          10.0.21.22 rocketmq-brokeras.cluster.local.
          10.0.21.21 rocketmq-brokerbs.cluster.local.
          10.0.21.20 rocketmq-brokera.cluster.local.
          10.0.21.25 rocketmq-brokerb.cluster.local.
          fallthrough
        }
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           fallthrough in-addr.arpa ip6.arpa
           ttl 30
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
kind: ConfigMap

你可能感兴趣的:(k8s,kubernetes,容器)