首页 > 其他分享 >k8s-codedns 域名解析

k8s-codedns 域名解析

时间:2022-11-14 15:55:06浏览次数:45  
标签:1.147 codedns yylending 域名解析 ip6 172.29 pod k8s com

1、 CoreDNS 的大多数功能都是由插件来实现的,插件和服务本身都使用了 Caddy 提供的一些功能,所以项目本身也不是特别的复杂。

pod与pod之间调用,可以通过名字或者svc直接访问(ectd数据库获取记录)。pod 访问外网通过宿主机网卡。

 

参考:https://www.cnblogs.com/cndr/p/15911802.html:v

一、

[yyapp@PH-K8S-M01 ~]$ 
[yyapp@PH-K8S-M01 ~]$  sudo kubectl describe configmap coredns  -n kube-system  
Name:         coredns
Namespace:    kube-system
Labels:       <none>
Annotations:  <none>

Data
====
Corefile:
----
.:53 {
    errors
    health
    kubernetes cluster.local in-addr.arpa ip6.arpa {
       pods insecure
       upstream
       fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    proxy . /etc/resolv.conf
    cache 30
    reload
}

Events:  <none>
[yyapp@PH-K8S-M01 ~]$ 

2、coredns解析过程。

1、先解析/etc/hosts (pod启动时候,yaml可以配置hostname) 

2、通过本机的 /etc/resolv.conf ,进行域名解析  (nameserver 10.96.0.10  代表的coderdns svc地址,然后找到coredns容器)

3、coredns容器主要通过etcd数据库查询pod 和svc 、statefu 等来进行解析

3、无法找到的通过宿主机网卡。

bash-4.4$ cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.244.4.167    yylending-testyylendingsit05-basic-67dbd98b9f-s8p7b

# Entries added by HostAliases.
172.29.1.147    testplmssit01image.yylending.com
172.29.1.147    testwptsit01.yylending.com
172.29.1.147    testwptsit02.yylending.com
172.29.1.147    testwptsit03.yylending.com
172.29.1.147    testwptsit04.yylending.com
172.29.1.147    testwptsit05.yylending.com
172.29.1.147    testwptsit06.yylending.com
172.29.1.147    testwptdev01.yylending.com
172.29.1.147    testwptdev02.yylending.com
172.29.1.147    testlcrmuat.yylending.com
172.29.1.147    testlassit01.yylending.com
172.29.1.147    testlassit02.yylending.com
172.29.1.147    testlassit03.yylending.com
172.29.1.147    testlas30219.yylending.com
172.29.1.147    testlassit05.yylending.com
172.29.1.147    testlassit06.yylending.com
172.29.1.147    testlassit07.yylending.com
172.29.1.147    testlassit08.yylending.com
172.29.1.147    testtasksit05.yylending.com

  

yyapp@LAPP-V714 ~]$ sudo  kubectl   exec -it busybox  /bin/sh
/ # 
/ # cat /etc/resolv.conf 
nameserver 10.96.0.10   #这里为coredns的svc地址
search default.svc.cluster.local svc.cluster.local cluster.local  #按照这个过程进行解析 如pod名字为conclient.
依次为:podname.search default.svc.cluster.local 等等最后才是宿主机
options ndots:5  #域名的.不超过5,超过5直接进行解析。不要通过上面的search。如 nsloolup  podname

  如果pod 提示域名不能解析到问题。1、通过手工yanl加 hostname解析  2、检查cordednss是否正常 3、宿主机网络是否正常 

 

标签:1.147,codedns,yylending,域名解析,ip6,172.29,pod,k8s,com
From: https://www.cnblogs.com/xiajq/p/16889258.html

相关文章