Kubernetes:PVC绑定状态为待定

时间:2018-12-03 16:20:07

标签: kubernetes

我创建了一个PV,并通过PVC声明了PV。我看到创建了PV,但PVC绑定状态停留在挂起状态。当我查看describe pvc输出时,我发现没有可用于该声明的持久卷,也没有设置存储类。从文档中,我了解到存储类不是强制性的。因此,不确定PVC文件中缺少什么。

apiVersion: v1

kind: PersistentVolume

metadata:
  name: pv-ghost
  labels:
    pv: pv-ghost

spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 3Gi

  hostPath:
    path: /ghost/data
--------------------------
apiVersion: v1

kind: PersistentVolumeClaim

metadata:
  name: pvc-ghost

spec:
  accessModes:
    - ReadWriteMany

  resources:
    requests:
      storage: 5Gi
  selector:
    matchLabels:
      pv: pv-ghost

无法描述PV和PVC

    kubectl describe pv pv-ghost
    Name:            pv-ghost
    Labels:          pv=pv-ghost
    Annotations:     <none>
    Finalizers:      [kubernetes.io/pv-protection]
    StorageClass:
    Status:          Available
    Claim:
    Reclaim Policy:  Retain
    Access Modes:    RWX
    Capacity:        3Gi
    Node Affinity:   <none>
    Message:
    Source:
        Type:          HostPath (bare host directory volume)
        Path:          /ghost/data
        HostPathType:
    Events:            <none>
kubectl describe pvc pvc-ghost
Name:          pvc-ghost
Namespace:     default
StorageClass:
Status:        Pending
Volume:
Labels:        <none>
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
Events:
  Type       Reason         Age                  From                         Message
  ----       ------         ----                 ----                         -------
  Normal     FailedBinding  8m44s (x8 over 10m)  persistentvolume-controller  no persistent volumes available for this claim and no storage class is set
  Normal     FailedBinding  61s (x5 over 2m3s)   persistentvolume-controller  no persistent volumes available for this claim and no storage class is set
Mounted By:  <none>

3 个答案:

答案 0 :(得分:0)

您需要手动指定卷源。

ReadWriteMany仅适用于AzureFileCephFSGlusterfsQuobyteNFSPortworxVolumeFlexvolume取决于驱动程序,VsphereVolume可以在并置Pod时工作。 您可以在Kubernetes文档中阅读有关Volume Mode

的全部内容

aws的PV示例如下:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-volume
spec:
  capacity:
    storage: 15Gi # Doesn't really matter, as EFS does not enforce it anyway
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  mountOptions:
    - hard
    - nfsvers=4.1
    - rsize=1048576
    - wsize=1048576
    - timeo=300
    - retrans=2
  nfs:
    path: /
    server: fs-XXX.efs.eu-central-2.amazonaws.com

答案 1 :(得分:0)

在以上问题中,

  1. 持久卷中指定的Capacity小于持久卷声明的容量。尝试将“持久性”卷中的Capacity数增加到 5Gi ,或将“持久性”卷声明中的Capacity数减少到 3Gi
  2. 持久卷中使用 hostPath 时,accessModes应该为ReadWriteOnce

答案 2 :(得分:0)

由于多节点群集中当前不支持Hostpath方法,因此结束了此问题。