Dynamic provisioning means defining a persistent volume claim (PVC) for the pods using a storage class similar to the storage class described in the Storage class configuration section.
Create a PVC yaml file (see the following example).
Apply the PVC yaml file and validate it is created successfully.
Apply the pvc .yaml file
# apply the pvc .yaml file
$ kubectl apply -f pvc-wekafs-dir.yaml
persistentvolumeclaim/pvc-wekafs-dir created
# check the pvc resource has been created
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc-wekafs-dir Bound pvc-d00ba0fe-04a0-4916-8fea-ddbbc8f43380 1Gi RWX storageclass-wekafs-dir 2m10s
Persistent volume claim parameters
The directory is created in the filesystem under the csi-volumes directory starting with the volume name.
Static provisioning
The Kubernetes admin can prepare persistent volumes in advance to be used by pods. The persistent volume must be an existing directory, and can contain pre-populated data used by the PODs.
The persistent volume can be a directory previously provisioned by the CSI or a an existing directory in the WEKA filesystem.
To expose an existing directory in the WEKA filesystem through the CSI, define a persistent volume, and bind the persistent volume claim to this persistent volume.
Create a PV yaml file (see the following example).
apiVersion:v1kind:PersistentVolumemetadata:name:pv-wekafs-dir-staticspec:storageClassName:storageclass-wekafs-diraccessModes: - ReadWriteManypersistentVolumeReclaimPolicy:RetainvolumeMode:Filesystemcapacity:storage:1Gicsi:driver:csi.weka.io# volumeHandle must be formatted as following:# dir/v1/<FILE_SYSTEM_NAME>/<INNER_PATH_IN_FILESYSTEM># The path must exist, otherwise publish request will failvolumeHandle:dir/v1/podsFilesystem/my-dir
Apply the PV yaml file and validate it is created successfully.
Apply the PV yaml file
# apply the pv .yaml file
$ kubectl apply -f pv-wekafs-dir-static.yaml
persistentvolume/pv-wekafs-dir-static created
# check the pv resource has been created
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pv-wekafs-dir-static 1Gi RWX Retain Available storageclass-wekafs-dir 3m33s
Persistent volume parameters
Bind a PVC to this specific PV using the volumeName parameter under the PVC spec and provide it with the specific PV name.
Example: persistent volume claim for static provisioning
Validate that the PVC resource is created and successfully bounded (the status is Bound).
Validate the PVC resource is created
# check the pv resource has been created
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pv-wekafs-dir-static 1Gi RWX Retain Bound default/pvc-wekafs-dir-static storageclass-wekafs-dir 6m30s
The volume access mode.
Possible values: ReadWriteMany, ReadWriteOnce, ReadOnlyMany
spec.storageClassName
The storage class to use to create the PVC.
The storage class must exist.
spec.resources.requests.storage
The required capacity for the volume.
The capacity quota is not enforced but is stored on the filesystem directory extended and attributed for future use.
spec.accessModes
The volume access mode.
Possible values: ReadWriteMany, ReadWriteOnce, ReadOnlyMany
spec.storageClassName
The storage class to use to create the PV.
The storage class must exist.
spec.capacity.storage
A required capacity for the volume.
The capacity quota is not enforced but is stored on the filesystem directory extended and attributed for future use.
spec.csi.volumeHandle
The path previously created.
A string containing the volumeType (dir/v1) filesystem name, and the directory path.
Example: dir/v1/podsFilesystem/my-dir
The filesystem and path must exist in the WEKA cluster.
spec.accessModes
The volume access mode.
Possible values: ReadWriteMany, ReadWriteOnce, ReadOnlyMany
spec.storageClassName
The storage class to use to create the PVC.
It must be the same storage class as the PV requested to bind in spec.volumeName.
spec.resources.requests.storage
The required capacity for the volume.
The capacity quota is not enforced but is stored on the filesystem directory extended and attributed for future use.
spec.volumeName
The name of a pre-configured persistent volume.
The persistent volume name must exist.