我正在尝试将stable/mongodb helm chart 安装到我在 IBM 云上的集群。我按照本指南配置对象存储服务实例,以及配置凭据和机密。
现在我想创建一个 persistenceVolumeClaim 并将其挂载到 stable/mongodb 安装。我尝试通过向稳定/图表提供的值添加正确的注释来创建 pvc persistence.annotations
,但是注释不会作为 pvc 的一部分呈现。那么我首先成功创建了一个pvc。
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
labels:
app: mongodb
annotations:
ibm.io/auto-create-bucket: "true"
ibm.io/auto-delete-bucket: "true"
ibm.io/bucket: ""
ibm.io/secret-name: "cos-write-access"
name: mypvc
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "10Gi"
storageClassName: ibmc-s3fs-standard-regional
pvc是绑定的
Name: mypvc
Namespace: default
StorageClass: ibmc-s3fs-standard-regional
Status: Bound
Volume: pvc-74a512ea-875c-4d57-850f-2df599bff46a
Labels: app=mongodb
release=hasher
Annotations: ibm.io/auto-create-bucket: true
ibm.io/auto-delete-bucket: true
ibm.io/bucket:
ibm.io/secret-name: cos-write-access
pv.kubernetes.io/bind-completed: yes
pv.kubernetes.io/bound-by-controller: yes
volume.beta.kubernetes.io/storage-provisioner: ibm.io/ibmc-s3fs
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 10Gi
Access Modes: RWO
VolumeMode: Filesystem
Mounted By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ExternalProvisioning 53m persistentvolume-controller waiting for a volume to be created, either by external provisioner "ibm.io/ibmc-s3fs" or manually created by system administrator
Normal Provisioning 53m ibm.io/ibmc-s3fs_ibmcloud-object-storage-plugin-c5dddccbd-dslv5_98f02393-5f15-11ea-aa3e-460564e82d0b External provisioner is provisioning volume for claim "default/hasher-pvc"
Normal ProvisioningSucceeded 53m ibm.io/ibmc-s3fs_ibmcloud-object-storage-plugin-c5dddccbd-dslv5_98f02393-5f15-11ea-aa3e-460564e82d0b Successfully provisioned volume pvc-74a512ea-875c-4d57-850f-2df599bff46a
然后我安装 helm chart 并将 pvc 的名称传递给带有
--set persistence.existingClaim=mypvc
. 但随后 pod 不断重新启动,失败并显示 readinessProbe 和错误消息:
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:341:17
@(connect):2:6
kubectl describe pod mongodb-pod
Name: mdb-mongodb-5fc7f858d6-cz4s2
Namespace: default
Priority: 0
Node: 10.144.180.104/10.144.180.104
Start Time: Fri, 06 Mar 2020 16:07:00 +0100
Labels: app=mongodb
chart=mongodb-7.8.7
pod-template-hash=5fc7f858d6
release=mdb
Annotations: kubernetes.io/psp: ibm-privileged-psp
Status: Running
IP: 172.30.180.57
IPs:
IP: 172.30.180.57
Controlled By: ReplicaSet/mdb-mongodb-5fc7f858d6
Containers:
mdb-mongodb:
Container ID: containerd://e563d7da6bfad26ece4b4bd8b0ba28774baf480c76c933610342eb097b8cf559
Image: docker.io/bitnami/mongodb:4.2.3-debian-10-r31
Image ID: docker.io/bitnami/mongodb@sha256:fc931d8dad56097d2d4d633f2d829b94a246d60652661b90d6e92432351e33f8
Port: 27017/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 06 Mar 2020 16:07:04 +0100
Ready: False
Restart Count: 0
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 'mdb-mongodb'> Optional: false
MONGODB_SYSTEM_LOG_VERBOSITY: 0
MONGODB_DISABLE_SYSTEM_LOG: no
MONGODB_ENABLE_IPV6: no
MONGODB_ENABLE_DIRECTORY_PER_DB: no
Mounts:
/bitnami/mongodb from data (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sdgp9 (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
data:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: mypvc
ReadOnly: false
default-token-sdgp9:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-sdgp9
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 600s
node.kubernetes.io/unreachable:NoExecute for 600s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 21s default-scheduler Successfully assigned default/mdb-mongodb-5fc7f858d6-cz4s2 to 10.144.180.104
Normal Pulled 17s kubelet, 10.144.180.104 Container image "docker.io/bitnami/mongodb:4.2.3-debian-10-r31" already present on machine
Normal Created 17s kubelet, 10.144.180.104 Created container mdb-mongodb
Normal Started 17s kubelet, 10.144.180.104 Started container mdb-mongodb
Warning Unhealthy 8s kubelet, 10.144.180.104 Readiness probe failed: MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-03-06T15:07:13.382+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:341:17
@(connect):2:6
2020-03-06T15:07:13.384+0000 F - [main] exception: connect failed
2020-03-06T15:07:13.384+0000 E - [main] exiting with code 1
日志:
15:09:24.47 Welcome to the Bitnami mongodb container
15:09:24.47 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-mongodb
15:09:24.47 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-mongodb/issues
15:09:24.47 Send us your feedback at containers@bitnami.com
15:09:24.48
15:09:24.48 INFO ==> ** Starting MongoDB setup **
15:09:24.51 INFO ==> Validating settings in MONGODB_* env vars...
15:09:24.51 INFO ==> Initializing MongoDB...
15:09:24.52 INFO ==> No injected configuration files found. Creating default config files...
15:09:26.12 INFO ==> Enabling authentication...
15:09:26.13 INFO ==> Deploying MongoDB with persisted data...
15:09:26.14 INFO ==>
15:09:26.14 INFO ==> ########################################################################
15:09:26.14 INFO ==> Installation parameters for MongoDB:
15:09:26.14 INFO ==> Persisted data and properties have been restored.
15:09:26.15 INFO ==> Any input specified will not take effect.
15:09:26.15 INFO ==> (Passwords are not shown for security reasons)
15:09:26.15 INFO ==> ########################################################################
15:09:26.15 INFO ==>
15:09:26.16 INFO ==> Loading custom scripts...
15:09:26.17 INFO ==> ** MongoDB setup finished! **
15:09:26.19 INFO ==> ** Starting MongoDB **
2020-03-06T15:09:26.227+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2020-03-06T15:09:26.231+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/bitnami/mongodb/data/db 64-bit host=mdb-mongodb-5fc7f858d6-cz4s2
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] db version v4.2.3
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] modules: none
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] build environment:
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] distmod: debian10
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] distarch: x86_64
2020-03-06T15:09:26.237+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-03-06T15:09:26.238+0000 I CONTROL [initandlisten] options: { config: "/opt/bitnami/mongodb/conf/mongodb.conf", net: { bindIp: "*", ipv6: false, port: 27017, unixDomainSocket: { enabled: true, pathPrefix: "/opt/bitnami/mongodb/tmp" } }, processManagement: { fork: false, pidFilePath: "/opt/bitnami/mongodb/tmp/mongodb.pid" }, security: { authorization: "enabled" }, setParameter: { enableLocalhostAuthBypass: "false" }, storage: { dbPath: "/bitnami/mongodb/data/db", directoryPerDB: false, journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, logRotate: "reopen", path: "/opt/bitnami/mongodb/logs/mongodb.log", quiet: false, verbosity: 0 } }
2020-03-06T15:09:29.988+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1463M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-03-06T15:10:48.815+0000 I CONTROL [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2020-03-06T15:10:48.815+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2020-03-06T15:10:48.815+0000 I - [signalProcessingThread] Stopping further Flow Control ticket acquisitions.
2020-03-06T15:10:48.815+0000 I CONTROL [signalProcessingThread] now exiting
2020-03-06T15:10:48.815+0000 I CONTROL [signalProcessingThread] shutting down with code:0
如果我通过了--set volumePermissions.enabled=true
,则 pod 会卡在 PodInitializing 状态,并在一段时间后使用 CrashLoopBackoff。
kubectl describe pod mdb-mongodb-6b99795f69-cchtm
Name: mdb-mongodb-6b99795f69-cchtm
Namespace: default
Priority: 0
Node: 10.144.180.104/10.144.180.104
Start Time: Fri, 06 Mar 2020 16:33:25 +0100
Labels: app=mongodb
chart=mongodb-7.8.7
pod-template-hash=6b99795f69
release=mongo
Annotations: kubernetes.io/psp: ibm-privileged-psp
Status: Pending
IP: 172.30.180.58
IPs:
IP: 172.30.180.58
Controlled By: ReplicaSet/mongo-mongodb-6b99795f69
Init Containers:
volume-permissions:
Container ID: containerd://23519443ca7d8ae5c980c4b51f5ed9e30ac03fff300471e26551078ee9f387b7
Image: docker.io/bitnami/minideb:buster
Image ID: docker.io/bitnami/minideb@sha256:2f430acaa0ffd88454ac330a6843840f1e1204007bf92f8ce7b654fd3b558d68
Port: <none>
Host Port: <none>
Command:
chown
-R
1001:1001
/bitnami/mongodb
State: Running
Started: Fri, 06 Mar 2020 16:33:53 +0100
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Fri, 06 Mar 2020 16:33:31 +0100
Finished: Fri, 06 Mar 2020 16:33:52 +0100
Ready: False
Restart Count: 1
Environment: <none>
Mounts:
/bitnami/mongodb from data (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sdgp9 (ro)
Containers:
mongo-mongodb:
Container ID:
Image: docker.io/bitnami/mongodb:4.2.3-debian-10-r31
Image ID:
Port: 27017/TCP
Host Port: 0/TCP
State: Waiting
Reason: PodInitializing
Ready: False
Restart Count: 0
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 'mongo-mongodb'> Optional: false
MONGODB_SYSTEM_LOG_VERBOSITY: 0
MONGODB_DISABLE_SYSTEM_LOG: no
MONGODB_ENABLE_IPV6: no
MONGODB_ENABLE_DIRECTORY_PER_DB: no
Mounts:
/bitnami/mongodb from data (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sdgp9 (ro)
Conditions:
Type Status
Initialized False
Ready False
ContainersReady False
PodScheduled True
Volumes:
data:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: mypvc
ReadOnly: false
default-token-sdgp9:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-sdgp9
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 600s
node.kubernetes.io/unreachable:NoExecute for 600s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 36s default-scheduler Successfully assigned default/mongo-mongodb-6b99795f69-cchtm to 10.144.180.104
Normal Pulling 9s (x2 over 32s) kubelet, 10.144.180.104 Pulling image "docker.io/bitnami/minideb:buster"
Normal Pulled 8s (x2 over 30s) kubelet, 10.144.180.104 Successfully pulled image "docker.io/bitnami/minideb:buster"
Normal Created 8s (x2 over 30s) kubelet, 10.144.180.104 Created container volume-permissions
Normal Started 8s (x2 over 30s) kubelet, 10.144.180.104 Started container volume-permissions
获取日志给了我错误信息:
kubectl logs mdb-mongodb-6b99795f69-cchtm
Error from server (BadRequest): container "mdb-mongodb" in pod "mdb-mongodb-6b99795f69-cchtm" is waiting to start: PodInitializing
我尝试使用 ceph 对象存储对其进行设置,并且开箱即用。我不明白问题出在哪里,任何帮助将不胜感激。