【发布时间】:2021-08-18 14:53:15
【问题描述】:
您好,我在 kubernetes 中遇到了问题。当我从一个 pod 进行 nslookup 时,我得到了正确的 ip:
~ kubectl -n exampleNamespace exec -it pod/curl -- nslookup exampleService.exampleNamespace
Defaulting container name to curl.
Use 'kubectl describe pod/curl -n exampleNamespace' to see all of the containers in this pod.
Server: 192.168.3.10
Address: 192.168.3.10:53
** server can't find exampleService.exampleNamespace: NXDOMAIN
Non-authoritative answer:
Name: exampleService.exampleNamespace
Address: 192.168.3.64
command terminated with exit code 1
192.168.3.64 是正确的 ip,但是当我尝试从同一命名空间中的 pod 卷曲这个 DNS 时,我得到了这个:
~ kubectl -n exampleNamespace exec -it pod/curl -- curl http://exampleService.exampleNamespace/path
Defaulting container name to curl.
Use 'kubectl describe pod/curl -n exampleNamespace' to see all of the containers in this pod.
curl: (6) Could not resolve host: exampleService.exampleNamespace
command terminated with exit code 6
Curl pod 使用以下 yaml 启动:
apiVersion: v1
kind: Pod
metadata:
name: curl
namespace: risk
spec:
containers:
- image: curlimages/curl
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: curl
restartPolicy: Always
【问题讨论】:
-
curl pod 中的 /etc/resolv.conf 是什么?
-
search exampleNamespace.svc.cluster.local svc.cluster.local cluster.local c.-redacted-.internal google.internal nameserver 192.168.3.10 options ndots:5 是 resolv.conf 的输出的卷曲荚。 :)
-
感谢大家的帮助,最终使用 buildpack-deps:curl 而不是 curlimages/curl 解决了这个问题。我运行了 k exec -it curl -- cat /etc/nsswitch.conf ,但我只是得到“cat: can't open '/etc/nsswitch.conf': No such file or directory”
标签: kubernetes curl dns