首页 > 解决方案 > 为什么 pod 状态仍然是“PENDING”?

问题描述

这是我得到的输出:

    [root@ip-10-0-3-103 ec2-user]# kubectl get pod --namespace=migration
    NAME                                          READY   STATUS    RESTARTS   AGE
    clear-nginx-deployment-cc77649fb-j8mzj        0/1     Pending   0          118m
    clear-nginx-deployment-temp-cc77649fb-hxst2   0/1     Pending   0          41s

无法理解 json 中显示的消息:

*"status": 
{
        "conditions": [
            {
                "message": "0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims.",

                "reason": "Unschedulable",
                "status": "False",
                "type": "PodScheduled"
            }
        ],
        "phase": "Pending",
        "qosClass": "BestEffort"
}*

如果你能帮助解决这个问题。stackoverflow 上的较早问题没有回答我的查询,因为我的消息输出不同。

标签: linuxkubernetesdevops

解决方案


这是因为您的 Pod 已被指示申请存储空间,但是,在您的情况下,有可用的存储空间。检查您的 Podkubectl get pods <pod-name> -o yaml并查看已应用于集群的确切 yaml。在那里,您应该能够看到 Pod 正在尝试声明 PersistentVolume (PV)。

要快速创建由hostPath应用以下 yaml 支持的 PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: stackoverflow-hostpath
  namespace: migration
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

Kubernetes 会以指数方式再次尝试调度 Pod;为了加快速度,请删除您的一个 pod ( kubectl delete pods <pod-name>) 以立即重新安排它。


推荐阅读