mongodb - Kubernetes mongodb 就绪探测失败
问题描述
我正在尝试为 mongodb 运行掌舵图,并且遇到了就绪/活跃度探测问题。来自 stable 存储库的 Mongodb helm chart 安装 pod 和服务。但是由于就绪探测,吊舱崩溃了。我可以尝试删除它们,但我想知道为什么会这样。
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
来自 pod 的日志 我检查了日志,没有什么值得注意的
`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 上运行相同的掌舵图,我遇到了完全相同的问题
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>
推荐阅读
- c++ - 分段错误:无法修复问题
- python - 如何在 Python 中返回递归函数的列表
- email - Drupal 8 - 用户帐户邮件
- typescript - 使用条件接口正确输入高阶函数返回函数
- azure - 我想对日期早于今天 powershell 的用户进行排序
- regex - 正则表达式匹配大括号之间的任何内容,除了个位数数字?
- php - PHP如何发送和接收多选框
- python - Pygame角色没有出现,我如何改变我的背景形状
- c++ - 无法让 SymGetTypeInfo 工作(错误 1,函数不正确)
- material-ui - 将 flex-grow 添加到材质 ui Grid