Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes : PVC binding status in pending

Tags:

kubernetes

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>
like image 977
IT_novice Avatar asked Dec 03 '18 16:12

IT_novice


People also ask

How can I check my PVC status in Kubernetes?

To check if the status of your persistence volumes, run the kubectl get pvc command. If the output message shows that your PVC status is pending and you are using a Bitnami Helm chart, this may be because your cluster does not support dynamic provisioning (such as a bare metal cluster).

How do you remove PVCs?

You can delete PVCs in using the kubectl delete command or from the F5 Console. To delete using kubectl, specify the PVC either by file or by name.


1 Answers

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
like image 75
Crou Avatar answered Sep 22 '22 03:09

Crou