Coredns自定义域名解析

修改coredns configmap

$ kubectl edit cm -n kube-system coredns
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health {
           lameduck 5s
        }
        hosts {
          192.168.99.181 k8s.lvzhenjiang.com
          fallthrough
        }

        ready
        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
metadata:
  name: coredns
  namespace: kube-system

重启coredns服务后,进行测试!

$ k exec busybox-86dbf5b9d8-tx8j8 -- ping k8s.lvzhenjiang.com
PING k8s.lvzhenjiang.com (192.168.99.181): 56 data bytes
64 bytes from 192.168.99.181: seq=0 ttl=63 time=0.536 ms
64 bytes from 192.168.99.181: seq=1 ttl=63 time=0.690 ms
64 bytes from 192.168.99.181: seq=2 ttl=63 time=2.023 ms
64 bytes from 192.168.99.181: seq=3 ttl=63 time=1.240 ms
posted @ 2021-12-29 19:02  吕振江  阅读(384)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end