Dear All, is PV necessary to use PVC inside a POD? Can't we use PVC with just a . . .

Nitin:
Dear All, is PV necessary to use PVC inside a POD? Can’t we use PVC with just a Storage Class?

Sathish Puranika K:
No, you need to create the PV with the storage class defined, then only you can claim that storageclass using PVC inside a pod/container.

Nitin:
Thank you @Sathish Puranika K for response. So that means PV is need to be created manually to use PVC ? please correct me if I am wrong

Anil:
Pv or sc is needed for pvc … pvc used in applications

Nitin:
Thanks @Anil for the response …

So I created storage class as below

apiVersion: <http://storage.k8s.io/v1|storage.k8s.io/v1>
kind: StorageClass
metadata:
name: manual
provisioner: <http://kubernetes.io/no-provisioner|kubernetes.io/no-provisioner>
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer

Then I created pvc as below

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi

Then I created pod using pvc as below

apiVersion: v1
kind: Pod
metadata:
name: pvc-pod
spec:
volumes:
- name: pvc-storage
persistentVolumeClaim:
claimName: pvc-claim
containers:
- name: pvc-container
image: nginx:alpine
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: pvc-storage

Then i got below error in the pod

Warning FailedScheduling 81s (x2 over 82s) default-scheduler 0/3 nodes are available: 1 node(s) had taint {http://node-role.kubernetes.io/master|node-role.kubernetes.io/master: }, that the pod didn’t tolerate, 2 node(s) didn’t find available persistent volumes to bind.

Nitin:
how to achieve pvc mounting inside pod without PV ?

Nitin:
I also tried changing volumeBindingMode to immediate inside SC but then I faced other error

Madhan Kumar:
You are referring to dynamic provisioning …if the provisioner defined inside your storage class supports dynamic provisioning then the pv will be automatically created when you reference the storage class from inside your pvc. . Check this link for more info…https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/|https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/

unnivkn:
Hi Nitin…please go through this. It will clear your questions. https://www.youtube.com/watch?v=AavnQzWDTEk

Madhan Kumar:
The provisioner ( http://kubernetes.io/no-provisioner|kubernetes.io/no-provisioner) that you had defined in your storage class does not support dynamic provisioning hence you need to create pv manually in this case…

Nitin:
Hey @Madhan Kumar and @unnivkn thank you so much fro your pointers … it will really help me to clear my concepts … :slightly_smiling_face::+1: