Creating Persistent Block Volume Storage
The Compute Cloud@Customer Block Volume service provides persistent, durable, and high-performance block storage that you can use to store data outside of containers.
This procedure automatically creates the requested oci-bv storage class; you don't need to create it. This procedure starts with using the kubectl command to create the persistent volume claim.
-
Create a persistent volume claim, specifying the storage class name
oci-bv.$ kubectl create -f csi-bvs-pvc.yamlThe following is the content of the
csi-bvs-pvc.yamlfile:apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mynginxclaim spec: storageClassName: "oci-bv" accessModes: - ReadWriteOnce resources: requests: storage: 50GiThe persistent volume claim name in the
metadatasection is user-specified. You can have more than one persistent volume claim on a persistent volume.For the value of
accessModes, specifyReadWriteOnce; don't useReadWriteMany.The value of the
storageproperty must be at least 50 gigabytes. -
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 4mThe PVC has a status of
Pendingbecause theoci-bvstorage class definition includes the following:volumeBindingMode: WaitForFirstConsumer -
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
mynginxclaimPVC as thenginxvolume, 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: mynginxclaimRun 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-bvRun the following command to verify that the pod is using the new PVC:
$ kubectl describe pod nginx