Unable to create POD using PVC and Storageclass

A) First i created storageclass:

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

B) Then i created PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
storageClassName: delayed-volume-sc

C) At last i created a POD:

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:

  • image: nginx:alpine
    name: nginx
    volumeMounts:
    • name: local-pvc-storage
      mountPath: /var/www/html
      volumes:
    • name: local-pvc-storage
      persistentVolumeClaim:
      claimName: local-pvc

Note: Issue is POD is getting into the pending state as PV is missing. Ideally Storageclass should have created PV (as per the storageclass lecture) automatically when my POD got created. Which did not happen. Please explain the reason.

1 Like

faced same issue. storage class not available in lab setup.
you can check with kubectl get sc.

I think i got the idea, reason is PV gets automatically created when we use cloud. Not on local-setup.