我正在尝试安装mongodb-replicasethelmchart 可在Rancher2(嗯,在我看来这主要是 k8s 的问题)。
mongodb-replicaset
该服务在命名空间中命名mongodb-replicaset
。
在初始化时,bootstrap
容器卡在等待peer-finder
命令。每隔几秒就会重复打印此日志:
lookup mongodb-replicaset on 10.43.0.10:53: read udp 10.42.8.5:54048->10.43.0.10:53: i/o timeout
知识产权(10.43.0.10)与中的相同/etc/resolv.conf
,但看起来 DNS 服务器没有及时响应。
> kubectl exec -i -t dnsutils -- cat /etc/resolv.conf
nameserver 10.43.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
我log
在相关的 ConfigMap 中添加了 coredns 选项,现在我可以看到对该服务发出的请求coredns
:
> kubectl logs --namespace=kube-system -l k8s-app=kube-dns -f
[INFO] 10.42.8.5:49418 - 22856 "SRV IN mongodb-replicaset.mongodb-replicaset.svc.cluster.local. udp 73 false 512" NOERROR qr,aa,rd 316 0.000214362s
[INFO] 10.42.8.5:47437 - 28407 "SRV IN mongodb-replicaset.svc.cluster.local. udp 54 false 512" NOERROR qr,aa,rd 147 0.000184052s
[INFO] 10.42.8.5:35926 - 3179 "SRV IN mongodb-replicaset.svc.cluster.local. udp 54 false 512" NOERROR qr,aa,rd 147 0.000168232s
[INFO] 10.42.8.5:52756 - 25514 "SRV IN mongodb-replicaset.cluster.local. udp 50 false 512" NXDOMAIN qr,aa,rd 143 0.000166371s
[INFO] 10.42.8.5:45189 - 5389 "SRV IN mongodb-replicaset. udp 36 false 512" NXDOMAIN qr,rd,ra 111 0.001224073s
[INFO] 10.42.8.5:34150 - 3084 "SRV IN mongodb-replicaset. udp 36 false 512" NXDOMAIN qr,aa,rd,ra 111 0.000131951s
当我尝试创建dig
或nslookup
连接到服务器时,两个命令都超时了:
> kubectl exec -i -t dnsutils -- dig serverfault.com
; <<>> DiG 9.11.6-P1 <<>> serverfault.com
;; global options: +cmd
;; connection timed out; no servers could be reached
command terminated with exit code 9
但我可以在日志中看到请求coredns
:
> kubectl logs --namespace=kube-system -l k8s-app=kube-dns -f
[INFO] 10.42.6.6:43125 - 1737 "A IN serverfault.com. udp 56 false 4096" NOERROR qr,rd,ra 157 0.001773677s
[INFO] 10.42.6.6:43125 - 1737 "A IN serverfault.com. udp 56 false 4096" NOERROR qr,aa,rd,ra 157 0.000264764s
[INFO] 10.42.6.6:43125 - 1737 "A IN serverfault.com. udp 56 false 4096" NOERROR qr,aa,rd,ra 157 0.000200713s
当我挖掘内部 FQDN 时,我得到了与上述相同的结果:dig mongodb-replicaset.mongodb-replicaset.svc.cluster.local.
顺便说一下,当我使用外部 DNS 服务器时,它可以按预期工作:
> kubectl exec -i -t dnsutils -- dig serverfault.com @8.8.8.8
; <<>> DiG 9.11.6-P1 <<>> serverfault.com @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16124
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;serverfault.com. IN A
;; ANSWER SECTION:
serverfault.com. 2414 IN A 151.101.65.69
serverfault.com. 2414 IN A 151.101.129.69
serverfault.com. 2414 IN A 151.101.193.69
serverfault.com. 2414 IN A 151.101.1.69
;; Query time: 15 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Oct 16 10:21:10 UTC 2020
;; MSG SIZE rcvd: 108
我是 k8s 世界的新手,对于如何解决这个问题我有点迷茫。我希望有好心人能指导我解决这个问题。
谢谢