我正在尝试使用https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/
在kubernetes中学习DNS。我部署了busybox
from multiprocessing import Process
p1 = Process(target=subprocess.call, args=(cmd,))
processTimeout = 50
p1.start()
p1.join(processTimeout)
if p1.is_alive():
p1.terminate()
kubectl get pods busybox -o wide
NAME READY STATUS RESTARTS AGE IP NODE
busybox 1/1 Running 0 16m 10.200.1.5 worker-1
kubectl exec -ti busybox -- nslookup kubernetes.default
是否需要修改worker-1节点的/etc/resolv.conf文件。当前/etc/resolv.conf内容在下面
Server: 10.32.0.10
Address 1: 10.32.0.10 kube-dns.kube-system.svc.cluster.local
nslookup: can't resolve 'kubernetes.default'
command terminated with exit code 1
也是worker-1的版本 lsb_release -a 没有可用的LSB模块。 发行人ID:Ubuntu 说明:Ubuntu 18.04.1 LTS 发行:18.04 代号:bionic
请帮助我找出导致配置错误的配置。我需要根据什么来更改resolve.conf文件吗?
答案 0 :(得分:1)
您遇到了最新版本的busybox docker映像中的错误。使用标签busybox:1.28
代替latest
。 bug link is here:
"Nslookup does not work in latest busybox image"
"1.27/1.28 are working , 1.29/1.29.1 are not"
这是带有<{1>}标签的失败。
busybox:latest
以下是带有$ kubectl run busybox --image busybox:latest --restart=Never --rm -it busybox -- sh
If you don't see a command prompt, try pressing enter.
/ # nslookup kubernetes.default
Server: 10.96.0.10
Address: 10.96.0.10:53
** server can't find kubernetes.default: NXDOMAIN
*** Can't find kubernetes.default: No answer
/ # exit
pod "busybox" deleted
标签的相同命令成功。
busybox:1.28
答案 1 :(得分:0)
尝试一下。
apiVersion: v1
kind: Pod
metadata:
name: dnsutils
namespace: default
spec:
containers:
- name: dnsutils
image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
restartPolicy: Always
save this in yaml format and run kubectl apply -f <filename>.yaml and then run below command
vagrant@kubemaster:~$ kubectl exec -i -t dnsutils -- nslookup 10-40-0-2.default.pod | tee nginx-pod
Server: 10.96.0.10
Address: 10.96.0.10#53
Name: 10-40-0-2.default.pod.cluster.local
Address: 10.40.0.2
It should resolve the output and save it in the file.