I would like to bound PersistentVolumeClaim with a gcePersistentDisk PersistentVolume. Below the steps I did for getting that:
With PersistentVolumeClaim, you don't need to create PersistentVolume objects or gcePersistentDisk. Instead, create only a PVC and Kubernetes automatically creates a PV object that references the backing storage.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: ssd-sc # specify the storage class created below
resources:
requests:
storage: 10Gi
Create a StorageClass so it knows which backing storage to use. You can specify that it retains the storage (reclaimPolicy: Retain) if you delete the PVC and the storage type (type: pd-ssd).
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ssd-sc
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Retain # Retain storage even if we delete PVC
parameters:
type: pd-ssd # ssd