kubernetes config_error ai_generated true

持久卷声明卡在Pending状态:未指定存储类

persistentvolumeclaim is stuck in Pending state: no storage class specified

ID: kubernetes/persistentvolumeclaim-stuck-pending-no-storageclass

其他格式: JSON · Markdown 中文 · English
88%修复率
87%置信度
1证据数
2023-09-15首次发现

版本兼容性

版本状态引入弃用备注
Kubernetes v1.26.6 active
Kubernetes v1.27.4 active
Kubernetes v1.28.1 active

根因分析

持久卷声明(PVC)卡在Pending状态,因为它没有指定storageClassName,并且集群没有配置默认的StorageClass。

English

A PersistentVolumeClaim (PVC) is stuck in Pending state because it doesn't specify a storageClassName and the cluster has no default StorageClass configured.

generic

官方文档

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storageclasses

解决方案

  1. Check existing StorageClasses: `kubectl get storageclass`. If none is set as default, set one: `kubectl patch storageclass <name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'`
  2. Update the PVC to specify an existing storage class: `kubectl edit pvc <pvc-name>` and add `spec.storageClassName: <existing-class-name>`

无效尝试

常见但无效的做法:

  1. Manually create a PersistentVolume (PV) with the same size 75% 失败

    Without a storage class, the PVC won't bind to a manually created PV unless the PV has the exact same label and access modes, and the PVC doesn't specify a selector. It's easier to configure a StorageClass.

  2. Delete and recreate the PVC with a random storageClassName 90% 失败

    Using a random or non-existent storage class name will still result in Pending state. The storage class must exist and be configured correctly.