在k8s 里面加域名解析hosts

kubectl edit configmap coredns -n kube-system

apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health {
           lameduck 5s
        }
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           fallthrough in-addr.arpa ip6.arpa
           ttl 30
        }
        hosts {
         182.92.29.16  maven.aliyun.com
         211.154.222.157  archiva-maven-storage-prod.oss-cn-beijing.aliyuncs.com
         59.110.190.73  oss-cn-beijing.aliyuncs.com
         fallthrough
        }
        prometheus :9153
        cache 30
        loop
        reload
        loadbalance
    }
kind: ConfigMap
metadata:
  creationTimestamp: "2023-04-13T02:27:14Z"
  name: coredns
  namespace: kube-system
  resourceVersion: "160191242"
  uid: bb9bce1e-6ef5-4b3c-8530-f6105cbea464

  这些解析域名的IP如何来的呢:

[root@node01 tmp]# ping maven.aliyun.com
PING tyjr-common-cn-beijing.aliyun.com.vipgds.alibabadns.com (182.92.29.16) 56(84) bytes of data.
64 bytes from 182.92.29.16 (182.92.29.16): icmp_seq=1 ttl=87 time=21.5 ms
64 bytes from 182.92.29.16 (182.92.29.16): icmp_seq=2 ttl=87 time=21.3 ms

[root@master01 ~]# ping archiva-maven-storage-prod.oss-cn-beijing.aliyuncs.com
PING archiva-maven-storage-prod.oss-cn-beijing.aliyuncs.com.gds.alibabadns.com (211.154.222.157) 56(84) bytes of data.
64 bytes from 211.154.222.157 (211.154.222.157): icmp_seq=1 ttl=83 time=20.2 ms
64 bytes from 211.154.222.157 (211.154.222.157): icmp_seq=2 ttl=83 time=20.0 ms
64 bytes from 211.154.222.157 (211.154.222.157): icmp_seq=3 ttl=83 time=20.0 ms
^C
--- archiva-maven-storage-prod.oss-cn-beijing.aliyuncs.com.gds.alibabadns.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 20.076/20.130/20.236/0.074 ms
[root@master01 ~]# ping oss-cn-beijing.aliyuncs.com
PING oss-cn-beijing.aliyuncs.com (59.110.190.79) 56(84) bytes of data.
64 bytes from 59.110.190.79 (59.110.190.79): icmp_seq=1 ttl=87 time=42.8 ms

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐