Kubernetes mongodb准备就绪探针故障

mcvgt66p  于 2022-12-17  发布在  Kubernetes
关注(0)|答案(3)|浏览(175)

我正在尝试运行mongodb的helm图表,但遇到了就绪/活动探测问题。稳定存储库中的Mongodb helm图表安装了pod和服务。但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

逃生舱的日志我查过日志了没什么值得注意的

`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
s5a0g9ez

s5a0g9ez1#

这与端口是否打开无关,看起来更像是mongo本身崩溃,准备探测失败。
您可以通过查看日志获得更多见解:

kubectl logs <pod-crashing-name> (-c <container-name-optionally)

您还可以通过ssh进入pod正在运行的节点并获取Docker日志

docker ps -a | grep mongo
docker logs <container-id-that-crashed>
l5tcr1uw

l5tcr1uw2#

我认为这可能是Bitnami Helm回购协议的问题。我将其从回购协议列表中删除,并使用了K8S回购协议中的Mongodb,效果很好。

cgh8pdjw

cgh8pdjw3#

我认为这个错误是最新版本中的一个bug。我将我的图像版本更改为以下:

containers:
  - image: mongo:5.0.11
    name: mongo

以及

对于其他图像,您可以看到:
https://hub.docker.com/_/mongo/tags?page=9

相关问题