Creating Persistent Block Volume Storage

The Private Cloud Appliance Block Volume service provides persistent, durable, and high-performance block storage for your data. See the Block Volume Storage Overview chapter in the Oracle Private Cloud Appliance Concepts Guide and the Block Volume Storage chapter in the Oracle Private Cloud Appliance User Guide for information about block volumes on the Private Cloud Appliance.

You can dynamically provision a block volume using the CSI plugin specified by the oci-bv storage class definition (provisioner: blockvolume.csi.oraclecloud.com). Then use the kubectl command to create the persistent volume claim.

  1. Create a persistent volume claim, specifying the storage class name oci-bv.

    $ kubectl create -f csi-bvs-pvc.yaml

    The following is the content of the csi-bvs-pvc.yaml file:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: mynginxclaim
    spec:
      storageClassName: "oci-bv"
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 50Gi

    The requested oci-bv storage class is automatically created; you do not need to create it.

    The persistent volume claim name in the metadata section is user-specified. You can have more than one persistent volume claim on a persistent volume.

    For the value of accessModes, specify ReadWriteOnce; do not use ReadWriteMany.

    The value of the storage property must be at least 50 gigabytes.

  2. Run the following command to verify that the PVC has been created:

    $ kubectl get pvc
    NAME           STATUS   VOLUME   CAPACITY   ACCESSMODES   STORAGECLASS   AGE
    mynginxclaim   Pending                                    oci-bv         4m

    The PVC has a status of Pending because the oci-bv storage class definition includes the following:

    volumeBindingMode: WaitForFirstConsumer
  3. Use the PVC when creating other objects, such as pods.

    For example, you could create a new pod from the following pod definition, which instructs the system to use the mynginxclaim PVC as the nginx volume, which is mounted by the pod at /data:

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:latest
          ports:
            - name: http
              containerPort: 80
          volumeMounts:
            - name: data
              mountPath: /usr/share/nginx/html
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: mynginxclaim

    Run the following command to verify that the PVC has been bound to a new PV:

    $ kubectl get pvc
    NAME           STATUS   VOLUME          CAPACITY   ACCESSMODES   STORAGECLASS   AGE
    mynginxclaim   Bound    csi-unique_ID   50Gi       RWO           oci-bv

    Run the following command to verify that the pod is using the new PVC:

    $ kubectl describe pod nginx