我正在尝试运行mongodb的 Helm 图表,并且遇到了准备就绪/活跃性问题。稳定存储库中的Mongodb掌 Helm chart 将安装Pod和服务。但是由于准备就绪探测器的原因, pods 坠毁了。我可以尝试删除它们,但是我想知道为什么会这样。
helm install --name mongodb stable/mongodb
kubectl describe pod mongodb-5ff464b5b9-nnz5x
Containers:
mongodb:
Container ID: docker://055f12c14992dc111ee8f0baff7faceafae6a16e518b27a174a7997408235afa
Image: docker.io/bitnami/mongodb:4.0.2-debian-9
Image ID: docker-pullable://bitnami/mongodb@sha256:6c050bf9063976e12aabb7bafcc7b2616df1e1dbbf19ac41b4799826abec92a3
Port: 27017/TCP
Host Port: 0/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 137
Started: Thu, 27 Sep 2018 17:54:01 -0400
Finished: Thu, 27 Sep 2018 17:55:50 -0400
Ready: False
Restart Count: 6
Liveness: exec [mongo --eval db.adminCommand('ping')] delay=30s timeout=5s period=10s #success=1 #failure=6
Readiness: exec [mongo --eval db.adminCommand('ping')] delay=5s timeout=5s period=10s #success=1 #failure=6
Environment:
MONGODB_ROOT_PASSWORD: <set to the key 'mongodb-root-password' in secret 'mongodb'> Optional: false
MONGODB_USERNAME:
MONGODB_DATABASE:
MONGODB_ENABLE_IPV6: yes
MONGODB_EXTRA_FLAGS:
Mounts:
/bitnami/mongodb from data (rw)
在错误部分,我看到以下内容。我需要做任何事情来打开集装箱港口吗?
connecting to: mongodb://127.0.0.1:27017
2018-09-27T21:43:04.664+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
Warning Unhealthy 6m kubelet, vm-b768f1df-3df6-4a79-50e5-9af633c6d9b9 Readiness probe failed: MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-27T21:43:14.670+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
Warning Unhealthy 6m kubelet, vm-b768f1df-3df6-4a79-50e5-9af633c6d9b9 Readiness probe failed: MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-27T21:43:24.657+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
编辑1
pods 中的日志
我检查了日志,没有什么值得注意的
`kubectl logs mongodb-5ff464b5b9-nnz5x -p`
------
Welcome to the Bitnami mongodb container
Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-mongodb
Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-mongodb/issues
nami INFO Initializing mongodb
mongodb INFO ==> Deploying MongoDB from scratch...
mongodb INFO ==> No injected configuration files found. Creating default config files...
编辑2
在GKE上运行了相同的 Helm 图表,我遇到了完全相同的问题
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 1m (x4 over 1m) default-scheduler PersistentVolumeClaim is not bound: "mongodb-bitnami" (repeated 3 times)
Normal Scheduled 1m default-scheduler Successfully assigned mongodb-bitnami-7b65895fd7-xr6gg to gke-cluster-default-pool-bec82955-xmhz
Normal SuccessfulMountVolume 1m kubelet, gke-cluster-default-pool-bec82955-xmhz MountVolume.SetUp succeeded for volume "default-token-whl5w"
Normal SuccessfulMountVolume 1m kubelet, gke-cluster-default-pool-bec82955-xmhz MountVolume.SetUp succeeded for volume "pvc-ddda94dd-c2c1-11e8-b2f0-42010af00119"
Normal Pulling 1m kubelet, gke-cluster-default-pool-bec82955-xmhz pulling image "docker.io/bitnami/mongodb:4.0.2-debian-9"
Normal Pulled 39s kubelet, gke-cluster-default-pool-bec82955-xmhz Successfully pulled image "docker.io/bitnami/mongodb:4.0.2-debian-9"
Normal Created 38s kubelet, gke-cluster-default-pool-bec82955-xmhz Created container
Normal Started 37s kubelet, gke-cluster-default-pool-bec82955-xmhz Started container
Warning Unhealthy 28s kubelet, gke-cluster-default-pool-bec82955-xmhz Readiness probe failed: MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-28T01:58:44.936+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
Warning Unhealthy 20s kubelet, gke-cluster-default-pool-bec82955-xmhz Readiness probe failed: MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-28T01:58:52.114+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
最佳答案
这与端口是否打开无关,它看起来更像mongo本身崩溃了,而就绪探针也失败了。
通过查看日志,您可以找到更多的见解:
kubectl logs <pod-crashing-name> (-c <container-name-optionally)
您还可以SSH进入Pod运行所在的节点,获取docker日志
docker ps -a | grep mongo
docker logs <container-id-that-crashed>