Create Distributed File Storage Volumes
Deploy distributed file storage volumes using PVCs on CKS
Distributed File Volumes are deployed as Persistent Volumes using Persistent Volume Claims (PVCs).
To create a Persistent Volume for a Distributed File Storage volume:
- Set the
accessModefor the PVC asReadWriteMany - Set the storage class as
shared-vast - Set the size to the desired size
- Specify the namespace in the manifest, as PVCs are created and scoped to a namespace.
- Cloud Console
- kubectl
To create a Distributed File Storage volume in Cloud Console:
- Select PVCs in the sidebar.
- Click the Create a PVC button.
The Create PVC editor includes both regular text fields and a manifest editor on the right side of the page. You can edit the manifest directly, or use the text fields to configure the PVC; any changes you make in one will be reflected in the other.
- Enter the desired name for the PVC in the Name field.
- Select the cluster where you want to deploy the PVC in the Cluster field.
- Select the namespace for the PVC in the Namespace field.
- The Disk Class dropdown may be pre-selected depending on the cluster you selected. If not, select the desired disk class from the dropdown.
- Set the size to the desired size in the Size field.
- Optionally, you can add labels to the PVC in the Labels field.
- Click Submit.
Here is an example of a PVC manifest for deploying a Distributed File Storage volume:
apiVersion: v1kind: PersistentVolumeClaimmetadata:name: new-pvcnamespace: defaultspec:accessModes:- ReadWriteManyresources:requests:storage: 1GistorageClassName: shared-vast
Once the manifest is created and configured as desired, apply it using kubectl. For example:
$kubectl apply -f sample-shared-fs.yaml
Attaching volumes to pods
You must create and provision storage volumes before they can be attached to a Pod.
To attach a Distributed File volume to a Pod, specify the mountPath and name under the volumeMounts stanza. Then, specify the volumes.name and the persistentVolumeClaim.claimName as shown in the following example:
apiVersion: v1kind: Podmetadata:name: filesystem-storage-examplespec:containers:- image: nginx:1.14.2name: nginxvolumeMounts:- mountPath: /storagename: filesystem-storagevolumes:- name: filesystem-storagepersistentVolumeClaim:claimName: new-pvc
Once the manifest is created and configured as desired, apply it using kubectl:
$kubectl apply -f sample-shared-fs-pod.yaml
Once the pod is created, you can verify that the volume is attached by running:
$kubectl describe pod filesystem-storage-example
This will show the volume attached to the pod in the Volumes section.
Changing volume sizes
After a volume is created and deployed, you can expand it or migrate to a smaller volume.
Existing volumes can't be reduced in size. To use a smaller volume, you'll need to create a new, smaller PVC and migrate your data manually.
Expanding volumes
You can expand deployed Distributed Filesystem Volumes without disrupting running workloads. After you've expanded a volume, you can't downsize it.
- Cloud Console
- kubectl
To expand a volume in Cloud Console, click the three-dot menu (⋮) on the far right of the volume in the Cloud Console sidebar, then click Edit.
Enter the desired size in the Size field, then click Confirm to expand the volume.
To expand a volume using kubectl, use kubectl patch to patch the existing volume manifest. For example, to expand a volume to 500Gi, run:
$kubectl patch pvc new-pvc -p \'{"spec":{"resources":{"requests":{"storage": "500Gi"}}}}'