【问题标题】:kube-dns with weave failing to lookup service带有 weave 的 kube-dns 无法查找服务
【发布时间】:2018-05-14 11:29:06
【问题描述】:

我在我的 Fedora 机器上用一个 vagrant 节点创建了一个 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 pod 的 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

任何帮助将不胜感激。

【问题讨论】:

  • 你能粘贴 `userservice-0` pod resolv.conf 文件吗?看到你可以从 resolve.conf 文件中删除 ndots 行并进行测试。
  • $ kubectl -n mynamespace exec userservice-0 -- cat /etc/resolv.conf nameserver 10.96.0.10 search mynamespace.svc.cluster.local svc.cluster.local cluster.local options ndots:5
  • 奇怪的是,如果我在 nslookup 命令中明确指定 DNS IP,它可以正常工作:$ kubectl -n mynamespace exec userservice-0 -- nslookup friendservice.mynamespace 10.96.0.10 Name: friendservice Address 1: 10.44.0.2 friendservice- 0.friendservice.mynamespace.svc.cluster.local

标签: kubernetes kubeadm kube-dns weave


【解决方案1】:

这是 Alpine Linux 及其 musl 库的问题。它破坏了 DNS 功能,并且多年来一直如此,他们显然并没有真正费心去修复它。

https://github.com/gliderlabs/docker-alpine/blob/master/docs/caveats.md#dns https://github.com/gliderlabs/docker-alpine/issues/8

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    • 2016-09-23
    相关资源
    最近更新 更多