Kubernetes : PVC binding status in pending

12/3/2018

I create a PV and claimed the PV through PVC. I see that PV is created but the PVC binding status is stuck in pending.When i looked at the describe pvc output , I see that no persistent volumes available for this claim and no storage class is set. From the documentation I understand that storage class isnt mandatory . So, am unsure on what's missing in the PVC file.

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

Out of describe PV and 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>
-- IT_novice
kubernetes

3 Answers

12/3/2018

In the above issue,

  1. The Capacity specified in the persistent volume is lesser than the Persistent volume claim Capacity. Try either increasing the Capacity number in the Persistent volume to 5Gi or reducing the Capacity number in the Persistent volume claim to 3Gi.
  2. When you are using a hostPath in the Persistent volume the accessModes should be ReadWriteOnce.
-- Venkata Surya Lolla
Source: StackOverflow

12/4/2018

Closing this question since Hostpath method is currently not supported in a multi node cluster .

-- IT_novice
Source: StackOverflow

12/3/2018

You need to specify the volume source manually.

ReadWriteMany is only available for AzureFile, CephFS, Glusterfs, Quobyte, NFS, PortworxVolume. Also Flexvolume depending on the drivers and VsphereVolume works when pods are collocated. You can read it all in Kubernetes docs regarding Volume Mode

An example PV for aws would look like this:

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
-- Crou
Source: StackOverflow