1.创建busybox的Pod
vim dns.yml
apiVersion: v1
kind: Pod
metadata:
name: dns
spec:
containers:
- image: busybox
name: busybox
command:
- /bin/sh
- -c
- 'sleep 3600'
或者
kubectl run dns --image=busybox --command -- /bin/sh -c 'sleep 3600'
2.进入busybox的Pod,测试nslookup
kubectl exec -it dns -- /bin/sh
nslookup解析Service名称nginx
[root@master01 cka]# kubectl exec -it dns -- /bin/sh
/ # nslookup nginx
Server: 10.96.0.10
Address: 10.96.0.10:53
** server can't find nginx.default.svc.cluster.local: NXDOMAIN
*** Can't find nginx.svc.cluster.local: No answer
*** Can't find nginx.cluster.local: No answer
*** Can't find nginx.default.svc.cluster.local: No answer
*** Can't find nginx.svc.cluster.local: No answer
*** Can't find nginx.cluster.local: No answer
可以看到新版本的busybox无法正常解析集群中Service名称
3.更改busybox镜像的版本,使用1.28.3
vim dns.yml
apiVersion: v1
kind: Pod
metadata:
name: dns
spec:
containers:
- image: busybox:1.28.3
name: busybox
command:
- /bin/sh
- -c
- 'sleep 3600'
kubectl apply -f dns.yml
或者
kubectl set image Pod dns busybox=busybox:1.28.3
4.进入Pod,测试nslookup命令
[root@master01 cka]# kubectl exec -it dns -- /bin/sh
/ # nslookup nginx
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name: nginx
Address 1: 10.99.29.162 nginx.default.svc.cluster.local
可以看到,使用busybox:1.28.3镜像,nslookup命令已经可以正常解析Service名称nginx了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)