gpt4 book ai didi

kubernetes - 为什么Kubernetes中的coredns无法解析Pod DNS记录

转载 作者:行者123 更新时间:2023-12-02 11:42:25 25 4
gpt4 key购买 nike

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

以上命令均无效。

最佳答案

使用图像busybox:1.28代替其他图像,因为这些图像存在DNS解析问题。

当您尝试使用Pod进行DNS解析时,您需要使用以下命令,该命令具有pod而不是svc

kubectl exec -it busy33 -- nslookup 10-36-0-1.default.pod.cluster.local

关于kubernetes - 为什么Kubernetes中的coredns无法解析Pod DNS记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62227255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com