博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kubernetes DNS——kube-dns命令
阅读量:6422 次
发布时间:2019-06-23

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

hot3.png

        kube-dns,是有针对kube 1.3版本的petset新增的,如果使用petset,又想访问Hostname,那就需要使用kube-dns。

        kube-dns命令在kube 1.3的源码包里有了,和kube-apiserver在同一目录下。

        kube-dns在kube的功能已完胜skydns和kube2sky,在kube 1.3版本中,虽然没有找到确切的资料,但是测试的效果已然说明了:

        ①、相同点:kube-dns和skydns、kube2sky均可用解析kube内部和外部的DNS

        ②、不同点:测试发现skydns、kube2sky,无法解析petset的DNS(web-0.nginx和web-0.nginx.default.svc.perofu.com)

#skydns、kube2sky可以解析

[root@web-0 /]# nslookup -type=srv nginx.default

Server:         192.168.16.100

Address:        192.168.16.100#53

nginx.default.svc.perofu.com    service = 10 50 0 c68268e8.nginx.default.svc.perofu.com.

nginx.default.svc.perofu.com    service = 10 50 0 4c018d1.nginx.default.svc.perofu.com.

[root@web-0 /]# nslookup nginx.default.svc.perofu.com

Server:         192.168.16.100

Address:        192.168.16.100#53

Name:   nginx.default.svc.perofu.com

Address: 172.22.3.2

Name:   nginx.default.svc.perofu.com

Address: 172.22.3.3

#skydns、kube2sky不可以解析

[root@web-0 /]# nslookup web-1.nginx

Server:         192.168.16.100

Address:        192.168.16.100#53

 

** server can't find web-1.nginx: NXDOMAIN

 

1、配置etcd

        Skydns是需要配置这一步的,但是kube-dns不需要etcd

etcdctl mk /skydns/config '{"dns-addr": "www.perofu.com:53", "ttl": 3600,"domain": "perofu.com.", "nameservers": ["223.5.5.5:53", "114.114.114.114:53"]}'

 

说明:

    dns-addr: 指定skydns启动时的监听地址

    ttl: 指域名的缓存的超时时间,单位秒

    domain: 集群中的私有域名,这里如果不指定,默认为skydns.local. ,注意最后的一个点

    nameservers:域名转发的dns列表,用来解析集群外部的域名

 

2、启动kube-dns:

 

 nohup /root/kubernetes_version/kube-1.3.4/kube-dns --dns-port=53 --domain=perofu.com --kube-master-url="http://192.168.16.100:8080" &

 

    Kube-dns会启动三个端口:

        ①、tcp 53 :解析dns

        ②、udp 53 :解析dns

        ③、tcp 8081 :状态检测(http://127.0.0.1:8081//readiness)和dns记录(http://127.0.0.1:8081/cache)

3、配置kubelet:

        在每个minion的kubelet启动时,加上--cluster-dns、 --cluster-domain参数,即可

nohup /usr/bin/kubelet --address=0.0.0.0 --port=10250 --hostname_override=192.168.16.240 --api_servers=http://192.168.16.100:8080  --cluster-dns=192.168.16.100 --cluster-domain=perofu.com --allow-privileged=true &

 

4、验证(nslookup):

[root@web-0 /]# nslookup -type=srv nginx.default 

Server:         192.168.16.100

Address:        192.168.16.100#53

nginx.default.svc.perofu.com    service = 10 50 0 c68268e8.nginx.default.svc.perofu.com.

nginx.default.svc.perofu.com    service = 10 50 0 4c018d1.nginx.default.svc.perofu.com.

[root@web-0 /]# nslookup nginx.default.svc.perofu.com

Server:         192.168.16.100

Address:        192.168.16.100#53

 

Name:   nginx.default.svc.perofu.com

Address: 172.22.3.2

Name:   nginx.default.svc.perofu.com

Address: 172.22.3.3

 

[root@web-1 /]# nslookup web-0.nginx

Server:         192.168.16.100

Address:        192.168.16.100#53

 

Name:   web-0.nginx.default.svc.perofu.com

Address: 172.22.3.2

 

[root@web-1 /]# nslookup web-1.nginx

Server:         192.168.16.100

Address:        192.168.16.100#53

 

Name:   web-1.nginx.default.svc.perofu.com

Address: 172.22.3.3

 

 

#解析外网

[root@web-1 /]# nslookup www.qq.com

Server:         192.168.16.100

Address:        192.168.16.100#53

 

Non-authoritative answer:

Name:   www.qq.com

Address: 59.37.96.63

Name:   www.qq.com

Address: 14.17.32.211

Name:   www.qq.com

Address: 14.17.42.40

 

[1288][root@www: kube-1.3_petset]# curl http://127.0.0.1:8081/readiness

ok

[1289][root@www: kube-1.3_petset]# curl http://127.0.0.1:8081/cache

{

        "ChildNodes": {

                "com": {

                        "ChildNodes": {

                                "perofu": {

                                        "ChildNodes": {

                                                "svc": {

                                                        "ChildNodes": {

                                                                "default": {

                                                                        "ChildNodes": {

                                                                                "kubernetes": {

                                                                                        "ChildNodes": {

                                                                                                "_tcp": {

                                                                                                        "ChildNodes": {

                                                                                                                "_https": {

                                                                                                                        "ChildNodes": {},

                                                                                                                        "Entries": {

                                                                                                                                "3362356536323463": {

                                                                                                                                        "host": "kubernetes.default.svc.perofu.com.",

                                                                                                                                        "port": 443,

                                                                                                                                        "priority": 10,

                                                                                                                                        "weight": 10,

                                                                                                                                        "ttl": 30

                                                                                                                                }

                                                                                                                        }

                                                                                                                }

                                                                                                        },

                                                                                                        "Entries": {}

                                                                                                }

                                                                                        },

                                                                                        "Entries": {

                                                                                                "3362356536323463": {

                                                                                                        "host": "10.1.0.1",

                                                                                                        "priority": 10,

                                                                                                        "weight": 10,

                                                                                                        "ttl": 30

                                                                                                }

                                                                                        }

                                                                                },

                                                                                "nginx": {

                                                                                        "ChildNodes": {

                                                                                                "_tcp": {

                                                                                                        "ChildNodes": {

                                                                                                                "_web": {

                                                                                                                        "ChildNodes": {},

                                                                                                                        "Entries": {

                                                                                                                                "web-0": {

                                                                                                                                        "host": "web-0.nginx.default.svc.perofu.com.",

                                                                                                                                        "port": 80,

                                                                                                                                        "priority": 10,

                                                                                                                                        "weight": 10,

                                                                                                                                        "ttl": 30

                                                                                                                                },

                                                                                                                                "web-1": {

                                                                                                                                        "host": "web-1.nginx.default.svc.perofu.com.",

                                                                                                                                        "port": 80,

                                                                                                                                        "priority": 10,

                                                                                                                                        "weight": 10,

                                                                                                                                        "ttl": 30

                                                                                                                                }

                                                                                                                        }

                                                                                                                }

                                                                                                        },

                                                                                                        "Entries": {}

                                                                                                }

                                                                                        },

                                                                                        "Entries": {

                                                                                                "web-0": {

                                                                                                        "host": "172.22.3.2",

                                                                                                        "priority": 10,

                                                                                                        "weight": 10,

                                                                                                        "ttl": 30

                                                                                                },

                                                                                                "web-1": {

                                                                                                        "host": "172.22.3.3",

                                                                                                        "priority": 10,

                                                                                                        "weight": 10,

                                                                                                        "ttl": 30

                                                                                                }

                                                                                        }

                                                                                }

                                                                        },

                                                                        "Entries": {}

                                                                }

                                                        },

                                                        "Entries": {}

                                                }

                                        },

                                        "Entries": {}

                                }

                        },

                        "Entries": {}

                }

        },

        "Entries": {}

}

转载于:https://my.oschina.net/fufangchun/blog/732762

你可能感兴趣的文章
jquery(插件)开发相关资料
查看>>
ansible 运维工具简单整理
查看>>
Java Tomcat SSL 服务端/客户端双向认证(一)
查看>>
程序员的几款利器
查看>>
我的友情链接
查看>>
【Jolla】离线更新方法
查看>>
InnoDB与MyISAM的区别
查看>>
MongoDB【最新版V2.6】- 系列 3: 架构的设计-Replica Sets
查看>>
Thinking in Java之hashCode()方法
查看>>
Unity定时器堆栈显示
查看>>
在spring security手动 自定义 用户认证 SecurityContextHolder
查看>>
AF3.1.0简单二次封装
查看>>
HTTP 缓存(上)
查看>>
Maclean答网友问:深入进阶学习Oracle数据库的规划
查看>>
Eclipse常用(默认)快捷键
查看>>
C#线程同步
查看>>
六大设计原则快速记忆SOLID
查看>>
解决windows10 9926版本中无法访问samba的方法
查看>>
【VMCloud云平台】拥抱Docker(二)配置第一个容器
查看>>
java中重写方法必须抛出和原方法一样的异常或者不抛异常
查看>>