博客
关于我
CoreDNS介绍
阅读量:421 次
发布时间:2019-03-06

本文共 3413 字,大约阅读时间需要 11 分钟。

本文介绍 CoreDNS 相关配置以及验证方法,实验环境为 Kubernetes 1.11,搭建方法参考

busybox 的槽点

开始之前先吐槽一下busybox中的nslookup命令。这个命令应该是实现的不是很完全,导致我在测试DNS的成功,得到了错误的信息。先来看一下

[root@devops-101 ~]# kubectl run busybox1 --rm -it --image=docker.io/busybox /bin/shIf you don't see a command prompt, try pressing enter./ # nslookup kubernetes.defaultServer:		172.17.0.10Address:	172.17.0.10:53** server can't find kubernetes.default: NXDOMAIN*** Can't find kubernetes.default: No answer

看起来像是DNS没有响应,慢着,使用带nslookup的alphine试一下。

[root@devops-101 ~]# kubectl run dig --rm -it --image=docker.io/azukiapp/dig /bin/shIf you don't see a command prompt, try pressing enter./ # dig @172.17.0.10 kubernetes.default.svc.cluster.local +noall +answer; <<>> DiG 9.10.3-P3 <<>> @172.17.0.10 kubernetes.default.svc.cluster.local +noall +answer; (1 server found);; global options: +cmdkubernetes.default.svc.cluster.local. 5	IN A	172.17.0.1/ # nslookup kubernetes.defaultServer:		172.17.0.10Address:	172.17.0.10#53Name:	kubernetes.default.svc.cluster.localAddress: 172.17.0.1/ # nslookup www.baidu.comServer:		172.17.0.10Address:	172.17.0.10#53Non-authoritative answer:www.baidu.com	canonical name = www.a.shifen.com.Name:	www.a.shifen.comAddress: 220.181.112.244Name:	www.a.shifen.comAddress: 220.181.111.188/ # nslookup kubernetes.defaultServer:		172.17.0.10Address:	172.17.0.10#53Name:	kubernetes.default.svc.cluster.localAddress: 172.17.0.1

好好的啊!就是这个原因,busybox坑了我好几天。

CoreDNS

CoreDNS在Kubernetes1.11版本已经做为GA功能释放,成为Kubernetes默认的DNS服务替代了Ku be-DNS,目前是kubeadm、kube-up、minikube和kops安装工具的默认选项。

Stubdomain and upstreamnameserver in kube-dns translates to the proxy in CoreDNS. The federation in kube-dns has an equivalent federation in CoreDNS.

配置文件

使用kubeadm安装CoreDNS,会使用ConfigMap做为配置文件。这份配置文件,会默认使用宿主机的DNS服务器地址。

[root@devops-101 ~]# kubectl -n kube-system get configmap coredns -oyamlapiVersion: v1data:  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    }kind: ConfigMapmetadata:  creationTimestamp: 2018-08-20T07:01:55Z  name: coredns  namespace: kube-system  resourceVersion: "193"  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns  uid: ec72baa4-a446-11e8-ac92-080027b7c4e9

配置文件各项目的含义

名称 含义
errors 错误会被记录到标准输出
health 可以通过http://localhost:8080/health查看健康状况
kubernetes 根据服务的IP响应DNS查询请求,kubeadm的Cluster DomainService CIDR默认为cluster.local10.95.0.0/12,可以通过--service-dns-domain--service-cidr参数配置。
prometheus 可以通过http://localhost:9153/metrics获取prometheus格式的监控数据
proxy 本地无法解析后,向上级地址进行查询,默认使用宿主机的 /etc/resolv.conf 配置
cache 缓存时间

检查COreDNS运行状况

检查Pod状态

[root@devops-101 ~]# kubectl -n kube-system get pods -o wideNAME                                 READY     STATUS    RESTARTS   AGE       IP              NODEcoredns-78fcdf6894-52gp9             1/1       Running   4          4h        172.16.0.11     devops-101coredns-78fcdf6894-mkvqn             1/1       Running   4          4h        172.16.0.10     devops-101etcd-devops-101                      1/1       Running   4          3h        192.168.0.101   devops-101

检查部署

[root@devops-101 ~]# kubectl -n kube-system get deploymentsNAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGEcoredns   2         2         2            2           4h

验证可以采用本文刚开始部分提到的方法。

参考资料

转载地址:http://jqrkz.baihongyu.com/

你可能感兴趣的文章
Nginx 中解决跨域问题
查看>>
nginx 代理解决跨域
查看>>
Nginx 做负载均衡的几种轮询策略分析
查看>>
Nginx 入门,一篇搞定!
查看>>
Nginx 利用代理转发请求示例
查看>>
Nginx 动静分离与负载均衡的实现
查看>>
Nginx 反向代理 MinIO 及 ruoyi-vue-pro 配置 MinIO 详解
查看>>
nginx 反向代理 转发请求时,有时好有时没反应,产生原因及解决
查看>>
Nginx 反向代理+负载均衡
查看>>
Nginx 反向代理解决跨域问题
查看>>
Nginx 反向代理配置去除前缀
查看>>
nginx 后端获取真实ip
查看>>
Nginx 多端口配置和访问异常问题的排查与优化
查看>>
Nginx 如何代理转发传递真实 ip 地址?
查看>>
Nginx 学习总结(16)—— 动静分离、压缩、缓存、黑白名单、性能等内容温习
查看>>
Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
查看>>
Nginx 学习(一):Nginx 下载和启动
查看>>
nginx 常用指令配置总结
查看>>
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>