This guide provides step by step instructions for configuring Portworx storage as a backend for persistent volumes created on your Kubernetes cluster.
This tutorial will use a Platform9 Managed Kubernetes Free Tier cluster, however you can use this tutorial to configure Portworx storage on any other Kubernetes cluster of your choice.
Once Portworx installation is running you need to create a storage class with the fowling configuration, this can be applied via the Platform9 UI using the Storage Class dashboards.
xxxxxxxxxxkindStorageClassapiVersionstorage.k8s.io/v1metadata nameportworx-csi-scprovisionerpxd.portworx.comparameters repl"1"
Next, enter the details for the storage class.

Finally, review the configuration, ensure it matches the example below including the replication parameter at the bottom of the YAML spec. Once the YAML is correct click Complete and Platform9 will create the storage class.
xxxxxxxxxxkindStorageClassapiVersionstorage.k8s.io/v1metadata nameportworx-csi-scprovisionerpxd.portworx.comparameters repl"1"You Portworx storage class is now created and should be listed under the Storage Classes tab.
You can test the CSI based storage class by creating a Kubernetes Persistent Volume Claim (PVC) with the following YAML spec and applying it to your cluster. Copy the YAML to a file locally and use kubectl to add the PVC. Ensure the StorageClassName matches the storage class that you created above
xxxxxxxxxxkindPersistentVolumeClaimapiVersionv1metadata namepx-mysql-pvcspec storageClassNameportworx-csi-sc accessModesReadWriteOnce resources requests storage2GiCreate the PVC from the YAML file with the command below:
xxxxxxxxxxkubectl apply -f pvc-test-portworx.yamlxxxxxxxxxxpersistentvolumeclaim/px-mysql-pvc createdTo view the state of the PVC run
xxxxxxxxxxkubectl get pvc px-mysql-pvcxxxxxxxxxxNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEpx-mysql-pvc Bound pvc-81fae0ac-fda5-43e3-a760-d93359079896 2Gi RWO portworx-csi-sc 8sThe following YAML spec creates an example MySQL application that uses the new PVC.
xxxxxxxxxxapiVersionapps/v1kindDeploymentmetadata namemysqlspec selector matchLabels appmysql strategy rollingUpdate maxSurge1 maxUnavailable1 typeRollingUpdate replicas1 template metadata labels appmysql version"1" spec containersimagemysql5.6 namemysql envnameMYSQL_ROOT_PASSWORD valuepassword portscontainerPort3306 volumeMountsnamemysql-persistent-storage mountPath/var/lib/mysql volumesnamemysql-persistent-storage persistentVolumeClaim claimNamepx-mysql-pvcUse Kubectl to apply the spec.
xxxxxxxxxxkubectl apply -f mysql-example.yamlRun the following command to view the running deployment:
kubectl get all -n defaultNAME READY STATUS RESTARTS AGEpod/mysql-67f5996b5f-jwctm 1/1 Running 0 3m53sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/kubernetes ClusterIP 10.21.0.1 <none> 443/TCP 98mNAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/mysql 1/1 1 1 3m53sNAME DESIRED CURRENT READY AGEreplicaset.apps/mysql-67f5996b5f 1 1 1 3m53s