I would like to bound PersistentVolumeClaim with a gcePersistentDisk PersistentVolume. Below the steps I did for getting that:
I found the solution.
Below the new definitions of the PV and PVC:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv
labels:
app: test # the label has been added to make sure the bounding is working as expected
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: gce-nfs-disk
fsType: ext4
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
labels:
app: test
spec:
accessModes:
- ReadWriteOnce
storageClassName: "" # the storageClassName has to be specified
resources:
requests:
storage: 2Gi
selector:
matchLabels:
app: test
After these modifications, this is the bounding worked:
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
nfs-pvc Bound nfs-pv 2Gi RWO 8s
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
nfs-pv 2Gi RWO Retain Bound default/nfs-pvc 22m
I hope it will help.