简体   繁体   中英

Why is my persistent volume claim pending?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM