Curl 无法使用 kubernetes dns 解析主机
Curl cant resolve host with kubernetes dns
您好,我在 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: exampleNamespace
spec:
containers:
- image: curlimages/curl
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: curl
restartPolicy: Always
原来将图像从 curlimages/curl 交换到 buildpack-deps:curl 解决了问题,但我不知道为什么。
工作 yaml:
apiVersion: v1
kind: Pod
metadata:
name: curl
namespace: exampleNamespace
spec:
containers:
- image: buildpack-deps:curl
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: curl
restartPolicy: Always
据一些网站报道,Alpine
和 Kubernetes
dns 解析似乎存在一些问题:
- https://www.openwall.com/lists/musl/2018/03/30/9
- Does Alpine have known DNS issue within Kubernetes?
- https://github.com/gliderlabs/docker-alpine/issues/8
- https://github.com/kubernetes/kubernetes/issues/30215
使用图像 curlimages/curl:7.77.0
按预期工作。
您好,我在 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: exampleNamespace
spec:
containers:
- image: curlimages/curl
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: curl
restartPolicy: Always
原来将图像从 curlimages/curl 交换到 buildpack-deps:curl 解决了问题,但我不知道为什么。
工作 yaml:
apiVersion: v1
kind: Pod
metadata:
name: curl
namespace: exampleNamespace
spec:
containers:
- image: buildpack-deps:curl
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: curl
restartPolicy: Always
据一些网站报道,Alpine
和 Kubernetes
dns 解析似乎存在一些问题:
- https://www.openwall.com/lists/musl/2018/03/30/9
- Does Alpine have known DNS issue within Kubernetes?
- https://github.com/gliderlabs/docker-alpine/issues/8
- https://github.com/kubernetes/kubernetes/issues/30215
使用图像 curlimages/curl:7.77.0
按预期工作。