【发布时间】:2018-11-01 08:30:55
【问题描述】:
我有一个主节点和 1 个节点的 kubernetes 安装。
它已配置好,一切运行良好。
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mantis-gfs 1/1 Running 1 22h
mongodb-gfs 1/1 Running 0 14h
我暴露了 pod mongodb-gfs:
$ kubectl expose pod mongodb-gfs --port=27017 --external-ip=10.9.8.100 --name=mongodb --labels="env=development"
外部IP 10.9.8.100是kubernetes主节点的IP
服务创建成功。
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
glusterfs-cluster ClusterIP 10.111.96.254 <none> 1/TCP 23d
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 29d
mongodb ClusterIP 10.100.149.90 10.9.8.100 27017/TCP 1m
现在我可以使用以下方式访问 mongo:
mongo 10.9.8.100:27017
这就是问题所在。它有一段时间有效,但有一段时间无效。 我连接一次并获得外壳,我第二次连接并获得:
$ mongo 10.9.8.100:27017
MongoDB shell version v3.4.17
connecting to: mongodb://10.9.8.100:27017/test
2018-11-01T09:27:23.524+0100 W NETWORK [thread1] Failed to connect to 10.9.8.100:27017, in(checking socket for error after poll), reason: Connection refused
2018-11-01T09:27:23.524+0100 E QUERY [thread1] Error: couldn't connect to server 10.9.8.100:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed
然后我再试一次,它工作,再试一次,它工作,再试一次,它不起作用......
任何线索可能导致问题?
【问题讨论】:
标签: networking kubernetes