前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Coredns 添加主机名解析,无法解析

Coredns 添加主机名解析,无法解析

作者头像
tanmx
发布2023-10-18 12:47:23
3050
发布2023-10-18 12:47:23
举报

在 coredns 的 configmap 添加了主机名解析

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

.: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 { 10.10.10.155 api-server01 #添加了这些 10.10.10.156 api-server02 10.10.10.157 api-server03 10.10.10.158 api-server04 10.10.10.159 api-server05 fallthrough } prometheus :9153 forward . /etc/resolv.conf { max_concurrent 1000 } cache 30 loop reload loadbalance }

通过 nodelocaldnscache 无法解析此主机名

1 2 3 4 5 6

nslookup api-server01 169.254.25.10 Server: 169.254.25.10 Address: 169.254.25.10#53 *** Can't find api-server01: No answer

通过 coredns 却是正常的

1 2 3 4 5 6 7

nslookup api-server01 11.253.0.3 Server: 11.253.0.3 Address: 11.253.0.3#53 Name: api-server01 Address: 10.10.10.155

原因分析:

查看 nodelocaldns 的 configmap 有如下部分

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

Corefile: | cluster.local:53 { errors cache { success 9984 30 denial 9984 5 } reload loop bind 169.254.25.10 forward . 11.253.0.3 { force_tcp } prometheus :9253 health 169.254.25.10:9254 } …… .:53 { errors cache 30 reload loop bind 169.254.25.10 forward . /etc/resolv.conf prometheus :9253 }

可以看到符合 k8s cluster.local 格式的域名 forward 是 coredns ,而其他的域名 forward 是 /etc/resolv.conf (主机系统的 dns),所以是解析不到自己添加在 coredns 中的主机名的。

解决方法:修改其他域名的 forward 也走 coredns

1 2 3 4 5 6 7 8 9 10

.:53 { errors cache 30 reload loop bind 169.254.25.10 forward . 11.253.0.3 { force_tcp } prometheus :9253

本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-12-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com