kubernetes - 为什么 Kubernetes 中的 coredns 无法解析 Pod DNS 记录
问题描述
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
推荐阅读
- android - How to shorten URL pointing to my server (NOT MOBILE APP)
- sql - 如何在两列中计算每年和每月'yyyy-mm'的出现次数(包括没有出现的期间)
- php - Prefill Date Field In PHP Form To Be 3 Days In The Future
- javascript - 使用 Datatables 行偏移量计算此 jquery 的工作原理
- python - 通过云功能以无服务器方式将数据从谷歌云存储移动到 Amazon s3
- php - 编辑表格时,它会更新数据库中的最后一个条目而不是选定的条目
- google-sheets - How do I find and delete duplicate values in a range of cells while keeping the first occurrence of a duplicated value in Google Sheets?
- javascript - Loading Default Component - Vue.js CDN
- ksh - 在 ksh 中等待所需远程交互的程序的缩进输出
- database - 如果没有任何具有 1 个属性的候选键,我如何找到关系的复合候选键?