我试图按照这个关于具有持久卷的 Kubernetes MongoDB 的链接(完全相同)。
但是在我部署所有内容并查看 pod 之后,我收到了以下错误:
Name: mongodb-standalone-0
Namespace: default
Priority: 0
Node: <none>
Labels: app=database
controller-revision-hash=mongodb-standalone-7688499856
selector=mongodb-standalone
statefulset.kubernetes.io/pod-name=mongodb-standalone-0
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Controlled By: StatefulSet/mongodb-standalone
Containers:
mongodb-standalone:
Image: mongo:4.0.8
Port: <none>
Host Port: <none>
Environment:
MONGO_INITDB_ROOT_USERNAME_FILE: /etc/k8-training/admin/MONGO_ROOT_USERNAME
MONGO_INITDB_ROOT_PASSWORD_FILE: /etc/k8-training/admin/MONGO_ROOT_PASSWORD
Mounts:
/config from mongodb-conf (ro)
/data/db from mongodb-data (rw)
/docker-entrypoint-initdb.d from mongodb-scripts (ro)
/etc/k8-training from k8-training (ro)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xbl5z (ro)
Conditions:
Type Status
PodScheduled False
Volumes:
k8-training:
Type: Secret (a volume populated by a Secret)
SecretName: k8-training
Optional: false
mongodb-scripts:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: mongodb-standalone
Optional: false
mongodb-conf:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: mongodb-standalone
Optional: false
mongodb-data:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: mongodb-standalone
ReadOnly: false
default-token-xbl5z:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-xbl5z
Optional: false
QoS Class: BestEffort
Node-Selectors: kubernetes.io/hostname=mongodb-node
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling <unknown> default-scheduler 0/1 nodes are available: 1 node(s) didn't match node selector.
Warning FailedScheduling <unknown> default-scheduler 0/1 nodes are available: 1 node(s) didn't match node selector.
结果kubectl get nodes --show-labels
:
minikube Ready master 43h v1.17.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=minikube,kubernetes.io/os=linux,node-role.kubernetes.io/master=
我试图找到一种方法来调试这个问题,什么都没有..
我成功地在 Kubernetes 中使用我的应用程序运行了我的 MongoDB,但问题是我想为我的数据提供持久的卷,但到目前为止我找不到正确的方法来让它工作。我很感激任何帮助,谢谢。
更新
我跟着更改了nodeSelector,但仍然遇到同样的错误:
Name: mongodb-standalone-0
Namespace: default
Priority: 0
Node: <none>
Labels: app=database
controller-revision-hash=mongodb-standalone-74895d955f
selector=mongodb-standalone
statefulset.kubernetes.io/pod-name=mongodb-standalone-0
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Controlled By: StatefulSet/mongodb-standalone
Containers:
mongodb-standalone:
Image: mongo:4.0.8
Port: <none>
Host Port: <none>
Environment:
MONGO_INITDB_ROOT_USERNAME_FILE: /etc/k8-training/admin/MONGO_ROOT_USERNAME
MONGO_INITDB_ROOT_PASSWORD_FILE: /etc/k8-training/admin/MONGO_ROOT_PASSWORD
Mounts:
/config from mongodb-conf (ro)
/data/db from mongodb-data (rw)
/docker-entrypoint-initdb.d from mongodb-scripts (ro)
/etc/k8-training from k8-training (ro)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xbl5z (ro)
Conditions:
Type Status
PodScheduled False
Volumes:
k8-training:
Type: Secret (a volume populated by a Secret)
SecretName: k8-training
Optional: false
mongodb-scripts:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: mongodb-standalone
Optional: false
mongodb-conf:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: mongodb-standalone
Optional: false
mongodb-data:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: mongodb-standalone
ReadOnly: false
default-token-xbl5z:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-xbl5z
Optional: false
QoS Class: BestEffort
Node-Selectors: kubernetes.io/hostname=minikube
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling <unknown> default-scheduler 0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.
Warning FailedScheduling <unknown> default-scheduler 0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.