Lab 02 - Understanding OpenShift Storage

In this step, we will create a StorageClass for Portworx volumes.

Understanding StorageClass

A StorageClass provides a way for administrators to describe the "classes" of storage available on their OpenShift cluster. Before we can create a volume in OpenShift, we need to create a StorageClass.

For example, below is a Portworx StorageClass whose volumes have:

  • Replication factor of 3: This means the data for the volume is replicated across 3 different nodes in the cluster.

  • High IO priority: Portworx will use storage devices that are classified under the high IO profile, such as SSDs.

Create the StorageClass by running the following command:

cat <<EOF | oc create -f -
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: px-repl3-sc
provisioner: pxd.portworx.com
parameters:
  repl: "3"
  priority_io: "high"
reclaimPolicy: Delete
volumeBindingMode: Immediate
EOF

Let’s proceed by creating volumes that use this StorageClass.

In this step, we will deploy a PersistentVolumeClaim using Portworx.

Understanding PersistentVolumeClaim

A PersistentVolumeClaim (PVC) can be used to dynamically create a volume using Portworx.

Below is the spec for a 2GB volume that uses the Portworx StorageClass we created earlier.

Let’s create the PersistentVolumeClaim:

cat <<EOF | oc create -f -
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: px-pvc
spec:
  storageClassName: px-repl3-sc
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
EOF

Behind the scenes, OpenShift communicates with the Portworx native driver to create this PVC. Each PVC has a unique one-to-one mapping to a PersistentVolume (PV), which is the actual volume backing the PVC.

Validate PersistentVolumeClaim

A PersistentVolumeClaim is successfully provisioned once it reaches the "Bound" state. Let’s run the following command to check its status:

oc get pvc px-pvc

You should see in the example output that our PVC is in the Bound state.

Let’s proceed to the next step to further inspect the volume.

Inspect the Portworx Volume

Now, we will use pxctl to inspect the underlying volume for our PVC.

pxctl volume inspect $(oc get pvc px-pvc -o jsonpath='{.spec.volumeName}')

Make the following observations in the inspect output:

  • HA: Shows the number of configured replicas for this volume.

  • Labels: Shows the name of the PVC associated with this volume.

  • Replica sets on nodes: Displays the Portworx nodes on which the volume is replicated.

  • State: Indicates whether the volume is currently "detached," meaning no applications are using the volume yet.