安装k8s coreDns

创建目录下载coreDns:

mkdir coredns && cd coredns
wget https://github.com/coredns/deployment/blob/master/kubernetes/deploy.sh
wget https://github.com/coredns/deployment/blob/master/kubernetes/coredns.yaml.sed

部署coreDns

# 10.254.0.2 dnsclusterIp  test.com当前域名
# yum -y install jq
# ./deploy.sh -i 10.254.0.2 -d test.com > coredns.yaml

# kubectl apply -f coredns.yaml
serviceaccount/coredns created
clusterrole.rbac.authorization.k8s.io/system:coredns created
clusterrolebinding.rbac.authorization.k8s.io/system:coredns created
configmap/coredns created
deployment.apps/coredns created
service/kube-dns created

# 查看
kubectl get pods --namespace kube-system
kubectl get svc --namespace kube-system

验证coreDns

# 验证
# kubectl run cirros-$RANDOM --rm -it --image=cirros -- sh
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.

/ # nslookup www.163.com
Server:    10.254.0.2
Address 1: 10.254.0.2 kube-dns.kube-system.svc.shuyuan.com

Name:      www.163.com
Address 1: 2408:8778:180:100:0:1:1:c
Address 2: 175.153.175.199
Address 3: 175.153.175.195
Address 4: 175.153.175.201
Address 5: 175.153.175.197
Address 6: 175.153.175.200
Address 7: 175.153.175.196
Address 8: 175.153.175.194

/ # ping nginx-web
PING nginx-web (10.254.47.180): 56 data bytes
64 bytes from 10.254.47.180: seq=0 ttl=64 time=0.047 ms
64 bytes from 10.254.47.180: seq=1 ttl=64 time=0.059 ms
64 bytes from 10.254.47.180: seq=2 ttl=64 time=0.066 ms

/ # ping www.163.com
PING www.163.com (175.153.175.195): 56 data bytes
64 bytes from 175.153.175.195: seq=0 ttl=53 time=5.052 ms
64 bytes from 175.153.175.195: seq=1 ttl=53 time=3.325 ms

/ # cat /etc/resolv.conf 
nameserver 10.254.0.2
search default.svc.test.com. svc.test.com. test.com. .test.com
options ndots:5
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
博客
32132
07-14 294
07-12 236

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值