Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "no persistent volumes available for this claim and no storage class is set"

Is it required to create the directory manually in nodes or will it be auto created by pv?

Here is my pv & pvc file, and I'm seeing this error

no persistent volumes available for this claim and no storage class is set

how to resolve this?

kind: PersistentVolume
apiVersion: v1
metadata:
name: zk1-pv
labels:
  type: local
spec:
storageClassName: manual
capacity:
  storage: 10Mi
accessModes:
  - ReadWriteOnce
hostPath:
  path: "/mr/zk"

cat zk1-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: zk1-pvc
spec:
accessModes:
  - ReadWriteOnce
resources:
  requests:
    storage: 10Mi


kubectl describe pvc zk1-pvc
Name:          zk1-pvc
Namespace:     instavote
StorageClass:
Status:        Pending
Volume:
Labels:        <none>
Annotations:   kubectl.kubernetes.io/last-applied-configuration:
               {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"zk1-pvc","namespace":"instavote"},"spec":{"accessMo...
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
Events:
Type       Reason         Age                  From                         Message
----       ------         ----                 ----                         -------
Normal     FailedBinding  12s (x14 over 3m7s)  *persistentvolume-controller  no persistent volumes available for this claim and no storage class is set*
Mounted By:  zk1-745b7cbf46-lg7v9
like image 734
Pooja Avatar asked Apr 21 '19 05:04

Pooja


People also ask

What are Kubernetes persistent volumes and persistent volume claims?

What Are Kubernetes Persistent Volumes and Persistent Volume Claims? A Kubernetes persistent volume (PV) is an object that allows pods to access persistent storage on a storage device, defined via a Kubernetes StorageClass. Unlike regular volumes, which are transient in nature, PVs are persistent, supporting stateful application use cases.

How to create a persistentvolume and storage class on local clusters?

PV and Storage classes on local clusters should be done manually by cluster admin. A cluster administrator creates a PersistentVolume that is backed by physical storage. The administrator does not associate the volume with any Pod. A cluster user creates a PersistentVolumeClaim, which gets automatically bound to a suitable PersistentVolume.

Does Minio-PV-claim bind to a persistent volume?

minio-pv-claim successfully binds to a persistent volume as intended. minio-pv-claim stalls forever with the message no persistent volumes available for this claim and no storage class is set I am not able to proceed through the installation due to this issue.

Why does the pod have unbound immediate persistent volume claims?

Looking into the events of the namespaces was seeing event entries as seen below. So basically the POD has unbound immediate Persistent volume Claims because no persistent volumes are available for the claim due to some issue with detecting the available storage class.


2 Answers

Back to your main question

Is it required to create the directory manually in nodes or will it be auto created by pv?

First of all, error in your output is not related with your question. As an answer for your question - Yes. It is crated by PV automatically.

In order to do achieve this, first you have to create StorageClass with no-provisioner as an example below

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

Then you have to create PersistentVolume by defining this storageClassName and hostPath parameter like below:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: zk1-pv
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /mr/zk

Then you have to create PVC and Pod/Deployment as an example below:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
    - name: containerName
      image: gcr.io/google-containers/nginx:1.7.9
      volumeMounts:
      - mountPath: "/var/www/html"
        name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: myclaim

NOTE:
Don't forget put storageClassName: manual parameter on both PVC and PV manifests. Otherwise they will not be able to bound to each other.

Hope it clears

like image 180
PjoterS Avatar answered Oct 02 '22 07:10

PjoterS


You forgot to specify storageClassName: manual in PersistentVolumeClaim.

like image 34
Vasili Angapov Avatar answered Oct 02 '22 06:10

Vasili Angapov