Creating a persistent volume
1. Create a file named ‘pv-demo.yaml’ in your editor of choice
2. Edit this file, and paste the below spec in.
3. Replace <pv_name> with the name of the PersistentVolume. For example pv0001
4. Change the storage capacity to your desired amount. The above example will create a 10 GiB volume.
5. Replace <volume_id> with the desired ID of the volume. For example, this could be “pv0001”.
6. Save this file
7. Create the persistent volume with the below command :
kubectl create –f pv-demo.yaml
8. You should receive the below message:
persistentvolume "pv0001" created
9. To see this persistent volume, run the below command:
kubectl get pv
10. You should see something similar to the below (depending on the name of the persistent volume, and the size you chose)
10. The volume has now been created, and is ready for a Persistent Volume Claim to use this.
To confirm this, we can check the storage usage (this will differ based on the underlying storage used). For Portworx, we can run pxctl status on one of the storage nodes to get the below information:
You will see that 10GiB has been provisioned, spread across the 5 storage nodes in the example Kubernetes environment.
For more information on Kubernetes persistent volume claims, please see this tutorial