If you have a single, large persistent volume (PV), you can create a storage pool by defining a PVC template in the hostpath provisioner (HPP) custom resource (CR).
A storage pool created with a PVC template can contain multiple HPP volumes. Splitting a PV into smaller volumes provides greater flexibility for data allocation.
The PVC template is based on the
spec stanza of the
volumeMode: Block (1)
||This value is only required for block volume mode PVs.
You define a storage pool using a
pvcTemplate specification in the HPP CR. The Operator creates a PVC from the
pvcTemplate specification for each node containing the HPP CSI driver. The PVC created from the PVC template consumes the single large PV, allowing the HPP to create smaller dynamic volumes.
You can combine basic storage pools with storage pools created from PVC templates.
Creating a storage pool with a PVC template
You can create a storage pool for multiple hostpath provisioner (HPP) volumes by specifying a PVC template in the HPP custom resource (CR).
Do not create storage pools in the same partition as the operating system. Otherwise, the operating system partition might become filled to capacity, which will impact performance or cause the node to become unstable or unusable.
hpp_pvc_template_pool.yaml file for the HPP CR that specifies a persistent volume (PVC) template in the
storagePools stanza according to the following example:
- name: my-storage-pool
path: "/var/myvolumes" (2)
volumeMode: Block (3)
storageClassName: my-storage-class (4)
storage: 5Gi (5)
storagePools stanza is an array that can contain both basic and PVC template storage pools.
||Specify the storage pool directories under this node path.
volumeMode parameter can be either
Filesystem as long as it matches the provisioned volume format. If no value is specified, the default is
Filesystem. If the
Block, the mounting pod creates an XFS file system on the block volume before mounting it.
storageClassName parameter is omitted, the default storage class is used to create PVCs. If you omit
storageClassName, ensure that the HPP storage class is not the default storage class.
||You can specify statically or dynamically provisioned storage. In either case, ensure the requested storage size is appropriate for the volume you want to virtually divide or the PVC cannot be bound to the large PV. If the storage class you are using uses dynamically provisioned storage, pick an allocation size that matches the size of a typical request.
Save the file and exit.
Create the HPP with a storage pool by running the following command:
$ oc create -f hpp_pvc_template_pool.yaml