ytong@controller-4135505:~/cka$ cat 14.15-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: busy33
labels:
app: 14-15
spec:
dnsPolicy: ClusterFirstWithHostNet
hostname: 14-15
subdomain: ytong82
containers:
- name: busybox-container
image: busybox
command: ['sleep', '3600']ytong@controller-4135505:~/cka$ kubectl get pods -o wide | grep busy33
busy33 1/1 Running 0 91s 10.36.0.1 worker3-4135521 <none> <none>我尝试解析它的pod DNS记录,如下所示
ytong@controller-4135505:~/cka$ kubectl exec -it busy33 -- nslookup -type=a 10-36-0-1.default.svc.cluster.local
Server: 10.96.0.10
Address: 10.96.0.10:53
** server can't find 10-36-0-1.default.svc.cluster.local: NXDOMAIN
command terminated with exit code 1
ytong@controller-4135505:~/cka$ kubectl exec -it busy33 -- nslookup -type=a 14-15.ytong82.default.svc.cluster.local
Server: 10.96.0.10
Address: 10.96.0.10:53
** server can't find 14-15.ytong82.default.svc.cluster.local: NXDOMAIN
command terminated with exit code 1以上两个命令都不起作用。
发布于 2020-06-06 12:28:59
使用镜像busybox:1.28而不是其他镜像,因为这些镜像有DNS解析问题。
当您尝试使用pod进行DNS解析时,您需要使用下面的命令,该命令使用pod而不是svc
kubectl exec -it busy33 -- nslookup 10-36-0-1.default.pod.cluster.local发布于 2020-06-06 13:29:36
将svc.cluster.local替换为pod.cluster.local,它适用于通过ip地址解析pod DNS名称
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name: 10-36-0-1.default.pod.cluster.local
Address 1: 10.36.0.1 busy33https://stackoverflow.com/questions/62227255
复制相似问题