Home > database >  Why is my persistent volume claim pending?
Why is my persistent volume claim pending?

Time:12-20

I'ts been 60min now and my persistent volume claim is still pending.

My storage class:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

Minikube did not supply this one, I had to add it with the yaml above. In the dashboard I can click on it and it references the persistent volume which is green/ok.

My persistent volume (green, ok):

apiVersion: v1
kind: PersistentVolume
metadata:
  name: small-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /data
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - minikube

The reason I need persistent storage is that nodered store its data in /data so that whats I'm trying to do here; provide it with persistent volume to store data. And since this is locally using minikube I can take advantage of /data folder on the minikube instance that per documentation is persistent.

My persistent volume claim for my nodered app.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nodered-claim
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

If I add the deployment or not, the persistent storage claim is still yellow/pending in the dashboard. Any reason for that? What am I missing here?

Update:

kubectl describe pvc/nodered-claim:

Type    Reason                Age                    From                         Message
  ----    ------                ----                   ----                         -------
  Normal  WaitForFirstConsumer  2m52s (x162 over 42m)  persistentvolume-controller  waiting for first consumer to be created before binding

CodePudding user response:

Update your StorageClass to immediate:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: Immediate  # <-- bind as soon as PVC is created

WaitForFirstConsumer will only bind when a Pod uses your PVC.

...If I add the deployment or not, the persistent storage claim is still yellow/pending in the dashboard.

Your deployment will also enter pending state if the PVC it needs failed to bind.

  • Related