how to bound a Persistent volume claim with a gcePersistentDisk?

后端 未结 2 580
温柔的废话
温柔的废话 2021-02-03 14:09

I would like to bound PersistentVolumeClaim with a gcePersistentDisk PersistentVolume. Below the steps I did for getting that:

1. Creation of the gcePersistentDisk:

2条回答
  •  清酒与你
    2021-02-03 15:11

    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
    

提交回复
热议问题