Cannot bind PersistentVolumeClaim to PersistentVolume in namespace

Viewed 746

I am trying to install jenkins on my kubernetes cluster under jenkins namespace. When I deploy my pv and pvc, the pv remains available and does not bind to my pvc.

Here is my yamls:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins
  labels:
    type: jenkins
spec:
  storageClassName: standard
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

Below is my Storageclass for manual. Standard class has not been changed, should be the same as the default standard on kubernetes.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"manual"},"provisioner":"kubernetes.io/no-provisioner","volumeBindingMode":"WaitForFirstConsumer"}
  creationTimestamp: "2021-06-14T14:41:39Z"
  name: manual
  resourceVersion: "3643100822"
  uid: 8254d900-58e5-49e1-a07e-1830096aac87
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

1 Answers

Based on the storage class spec, I think the problem is the volumeBindingMode being set as WaitForFirstConsumer which means the PV will remain unbound until there is a Pod to consume it.

You can change it Immediate to allow the PV to be bound immediately without requiring to create a Pod.

You can read about the different volume binding modes in detail in the docs.

Related