Kubernetes主节点DNS无法发现服务名称

时间:2019-04-10 02:17:25

标签: kubernetes

我有两个节点,主节点和从节点。除了一件事情,他们实际上运作良好。主节点无法发现服务名称。从节点运行正常,没有问题。

我在两个节点上都安装了dnstools docker。 它们的/etc/resolv.conf文件完全相同。

root@pvgl50934100b:~# kubectl get nodes
NAME                              STATUS   ROLES    AGE   VERSION
my-master   Ready    master   84d   v1.13.2
pvgl50934100b                     Ready    <none>   17h   v1.13.2

root@pvgl50934100b:~# kubectl  get pods -o wide | grep dnstools
dnstools-5c57c4d457-695hs                     1/1     Running   16         16h   10.244.12.13   pvgl50934100b                     <none>           <none>
dnstools-5c57c4d457-fvhts                     1/1     Running   15         15h   10.244.0.125   my-master   <none>           <none>
root@pvgl50934100b:~# kubectl  exec dnstools-5c57c4d457-695hs -- cat /etc/resolv.conf
nameserver 10.244.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

root@pvgl50934100b:~# kubectl  exec dnstools-5c57c4d457-fvhts -- cat /etc/resolv.conf
nameserver 10.244.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

我的端点配置:

- apiVersion: v1
  kind: Endpoints
  metadata:
    creationTimestamp: "2019-01-24T10:05:42Z"
    labels:
      addonmanager.kubernetes.io/mode: Reconcile
      k8s-app: kube-dns
      kubernetes.io/cluster-service: "true"
      kubernetes.io/name: CoreDNS
    name: kube-dns
    namespace: kube-system
    resourceVersion: "9725462"
    selfLink: /api/v1/namespaces/kube-system/endpoints/kube-dns
    uid: 9bc1c68d-1fbf-11e9-a68f-4ccc6a74038f
  subsets:
  - addresses:
    - ip: 10.244.0.124
      nodeName: my-master
      targetRef:
        kind: Pod
        name: coredns-779bd65884-8m4j4
        namespace: kube-system
        resourceVersion: "9725461"
        uid: f2fda560-5ab1-11e9-a68f-4ccc6a74038f
    - ip: 10.244.12.15
      nodeName: pvgl50934100b
      targetRef:
        kind: Pod
        name: coredns-779bd65884-488s2
        namespace: kube-system
        resourceVersion: "9725429"
        uid: eedbd034-5ab1-11e9-a68f-4ccc6a74038f
    ports:
    - name: dns
      port: 53
      protocol: UDP
    - name: dns-tcp
      port: 53
      protocol: TCP

我的服务:

kube-dns                NodePort   10.244.0.10      <none>        53:30765/UDP,53:30765/TCP   75d

dig的测试结果:

root@pvgl50934100b:~# kubectl  exec dnstools-5c57c4d457-695hs -- dig -t Mx kubernetes

; <<>> DiG 9.11.3 <<>> -t Mx kubernetes
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 12552
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;kubernetes.            IN  MX

;; AUTHORITY SECTION:
.           30  IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2019040903 1800 900 604800 86400

;; Query time: 137 msec
;; SERVER: 10.244.0.10#53(10.244.0.10)
;; WHEN: Wed Apr 10 02:02:17 UTC 2019
;; MSG SIZE  rcvd: 114

root@pvgl50934100b:~# kubectl  exec dnstools-5c57c4d457-fvhts -- dig -t Mx kubernetes

; <<>> DiG 9.11.3 <<>> -t Mx kubernetes
;; global options: +cmd
;; connection timed out; no servers could be reached
command terminated with exit code 9

我不确定我还可以使用其他工具或位置来检查配置。 期望主节点获得与从节点相同的结果。

任何建议/建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

我不确定它是怎么来的,但是只要两个coredns在两个不同的节点上运行,我就再次重新初始化主服务器,并且一切正常。两者都可以使用dig并返回正确的响应。