我在Fedora机器上通过一个无用节点创建了一个kubeadm(Kubernetes 1.8)集群。群集运行良好,但是在测试dns时遇到了一个奇怪的问题:
$ kubectl exec busybox -- nslookup friendservice.mynamespace Server: 10.96.0.10 Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local Name: friendservice.mynamespace Address 1: 10.44.0.2 friendservice- 0.friendservice.mynamespace.svc.cluster.local $ kubectl -n mynamespace exec userservice-0 -- nslookup friendservice.mynamespace nslookup: can't resolve '(null)': Name does not resolve Name: friendservice Address 1: 10.44.0.2 friendservice- 0.friendservice.mynamespace.svc.cluster.local
从mynamespace命名空间中运行的服务的默认命名空间中的busybox窗格中的nslookup正常工作,但是似乎当我尝试在同一自定义命名空间(mynamespace)中对服务进行nslookup时,dns首先无法解析,但随后解析。我在这里想念什么?
$ kubectl get pods --all-namespaces kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default busybox 1/1 Running 2 2h kube-system etcd-fed-master 1/1 Running 6 2h kube-system kube-apiserver-fed-master 1/1 Running 0 2h kube-system kube-controller-manager-fed-master 1/1 Running 0 2h kube-system kube-dns-545bc4bfd4-jkhrr 3/3 Running 0 2h kube-system kube-proxy-5vcvr 1/1 Running 0 2h kube-system kube-proxy-f4765 1/1 Running 0 2h kube-system kube-scheduler-fed-master 1/1 Running 1 2h kube-system weave-net-jw647 2/2 Running 0 2h kube-system weave-net-z25rv 2/2 Running 0 2h mynamespace friendservice-0 1/1 Running 5 10m mynamespace userservice-0 1/1 Running 0 26m $ kubectl exec busybox -- cat /etc/resolv.conf nameserver 10.96.0.10 search default.svc.cluster.local svc.cluster.local cluster.local options ndots:5 $ kubectl -n mynamespace exec bookentryservice-0 -- cat /etc/resolv.conf nameserver 10.96.0.10 search mynamespace.svc.cluster.local svc.cluster.local cluster.local options ndots:5
任何帮助将不胜感激。