当前已经开启ipvs的kube-proxy,集群DNS的IP为10.254.0.2
集群DNS IP可以查看kubelet服务的配置中查看

下载coredns项目的kubernetes
wget https://github.com/coredns/deployment/archive/master.zip
yum -y install unzip
unzip master.zip

因为项目使用了jq命令,需要安装jq程序
由于jq来源于epel,因此需要安装扩展的yum仓库
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install jq

上面下载master.zip解压缩至deployment-master文件夹
cd deployment-master/kubernetes
./deploy -h #查看部署帮助
./deploy.sh -r 10.254.0.0/16 -i 10.254.0.2 -d cluster.local | kubectl apply -f -

查看日志发现
Sep 11 22:01:05 node210 kube-proxy: E0911 22:01:05.726990 860 proxier.go:1451] Failed to delete kube-system/kube-dns:dns endpoint connections, error: error deleting conntrack entries for UDP peer {10.254.0.2, 172.30.17.3}, error: error looking for path of conntrack: exec: "conntrack": executable file not found in $PATH

可以看到缺少conntrack文件
yum -y install conntrack-tools

测试Core-DNS是否部署成功

kubectl run nginx --image=nginx --port=80
kubectl expose deployment nginx
kubectl get svc 

[root@node210 ~]# kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.254.0.1               443/TCP   6d
nginx        ClusterIP   10.254.240.205           80/TCP    5s

由上面可以看到nginx对应的cluster ip为10.254.240.205,而kubernetes对应的为10.254.0.1

kubectl run -it --rm busybox --image=busybox /bin/sh

然后
ping nginx.default.svc.cluster.local
ping nginx
ping kubernetes

kubernetes 1.11.2安装配置Core-DNS_第1张图片

注意这里不要使用nslookup. nslookup解析不到。用ping就可以,如果有知道原因,请评论留言。