Dynamic and static provisioning

The section provides some examples of dynamic and static provisioning. For more examples, see https://github.com/weka/csi-wekafs/tree/main/examples.

Dynamic provisioning

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.

Procedure

  1. Create a PVC yaml file (see the following example).

Example: pvc-wekafs-dir.yaml
csi-wekafs/examples/dynamic/pvc-wekafs-dir.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-wekafs-dir
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: storageclass-wekafs-dir
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi
  1. 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

ParameterDescription

spec.accessModes

Defines the access mode for the volume. Possible values include: ReadWriteMany, ReadWriteOnce, ReadOnlyMany

spec.storageClassName

Storage class for PV creation. Specifies the storage class to be used when creating the Persistent Volume (PV). The storage class must already exist.

spec.resources.requests.storage

Required capacity for the volume. The specified capacity is not enforced but is recorded as a quota within the filesystem directory's extended attributes for future reference.

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.

You can use an existing storage class from dynamic provisioning for static provisioning. However, the Persistent Volume parameters (filesystemName, filesystemGroupName, and volumeType) will override those in the storage class.

Procedure

  1. Create a PV yaml file (see the following example).

Example: PV yaml file
csi-wekafs/examples/static/pv-wekafs-dir-static.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-wekafs-dir-static
spec:
  storageClassName: storageclass-wekafs-dir
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  volumeMode: Filesystem
  capacity:
    storage: 1Gi
  csi:
    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 fail
    volumeHandle: dir/v1/podsFilesystem/my-dir
  1. 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

ParameterDescription

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.

  1. 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
csi-wekafs/examples/static/pvc-wekafs-dir-static.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-wekafs-dir-static
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: storageclass-wekafs-dir
  volumeName: pv-wekafs-dir-static
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi

Persistent volume claim for static provisioning

ParameterDescription

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.

  1. Validate that the PVC resource is created and successfully bounded (the status is Bound).

Validate that 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

Last updated