The Container Storage Interface (CSI) plug-in supports quota limits for subdirectories in General-purpose NAS volumes. When a NAS subdirectory is mounted via subPath, directory quotas can be enabled to cap capacity and improve utilization. When the quota is reached, the subdirectory can be expanded online by increasing the PVC size without service interruption.
Prerequisites
The CSI component is installed in your cluster and the version is v1.18.8.45 or later. To upgrade the component, see Update csi-plugin and csi-provisioner.
A NAS file system and mount target have been created and meet the following conditions:
The NAS type is General-purpose NAS and the Protocol Type is NFS. If not, create a General-purpose NAS file system again.
The mount target and cluster nodes are in the same VPC, and the Status is Active. If not, create a new mount target. For more information, see Manage mount targets.
Limits
The directory quota feature is supported only for dynamically provisioned NAS volumes that use the NFS protocol with General-purpose NAS and are mounted using the subpath method. Statically provisioned NAS volumes and dynamically provisioned NAS volumes mounted using the sharepath or filesystem method do not support this feature.
For more information about the limitations of the directory quota feature, see Directory quotas.
Example
Modify the following YAML content and save it as alicloud-nas-quota-sc.yaml.
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: alicloud-nas-quota-sc mountOptions: - nolock,tcp,noresvport - vers=3 parameters: volumeAs: subpath # Set the value to subpath. server: "0cd8b4a576-g****.cn-hangzhou.nas.aliyuncs.com" # The mount target of the General-purpose NAS file system that uses the NFS protocol. archiveOnDelete: "false" path: "/test" volumeCapacity: "true" # The dynamically provisioned volume supports the directory quota feature. provisioner: nasplugin.csi.alibabacloud.com reclaimPolicy: Delete allowVolumeExpansion: true # Enable the directory quota feature to allow expansion of dynamically provisioned volumes.NoteTo enable the directory quota feature, set
allowVolumeExpansionorvolumeCapacitytotrue. IfallowVolumeExpansionis set totrue, thevolumeCapacityparameter does not take effect, and the directory quota feature remains enabled.Pay attention to the following parameters. For more information, see Use dynamically provisioned NAS volumes.
Parameter
Description
parametersvolumeAsWhen you use the directory quota feature, you must set this parameter to
subpath, which indicates that a subdirectory of the NAS file system is mounted as a PV.serverThe mount target of the NAS file system. For more information about how to view the mount target address, see Manage mount targets.
pathThe subdirectory of the NAS file system that is mounted. The default value is
/. For Extreme NAS file systems, the path must start with/share.volumeCapacitySpecifies whether to enable the directory quota feature.
If
allowVolumeExpansionis set totrue, this parameter does not take effect, and the quota feature remains enabled.allowVolumeExpansionThis parameter is available only for General-purpose NAS file systems. If you set this parameter to true, a quota is configured for the PV that is dynamically provisioned using the StorageClass.
Create the StorageClass.
kubectl apply -f alicloud-nas-quota-sc.yaml
Verify the result
Write 10 GiB of data to the /data directory mounted by the StatefulSet in Step 2.
dd if=/dev/zero of=10G.txt bs=1M count=10000After 5 to 15 minutes, check the quota details of the subdirectory.
Log on to the NAS console.
In the left-side navigation pane, choose .
Find the file system and click the
icon in the Actions column. Then, click Quota Management. On the Quota Management page, click Manage Quotas in the Actions column.
The subdirectory has a quota limit of 20 GiB with 9 GiB currently used.
When the 20 GiB quota is reached, further writes return the
Disk quota exceedederror appears.
When the quota is reached, expand the volume online.
Expand the volume:
NoteVolume expansion does not interrupt running services.
kubectl patch pvc nas-pvc-0 -p '{"spec":{"resources":{"requests":{"storage":"30Gi"}}}}'Query PV information:
kubectl get pvExpected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE nas-63c37cc2-b21e-4b56-b26f-**** 30Gi RWX Delete Bound default/nas-pvc-0 alicloud-nas-quota-sc 25m23sQuery PVC information:
kubectl get pvcExpected output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE nas-pvc-0 Bound nas-63c37cc2-b21e-4b56-b26f-**** 30Gi RWX alicloud-nas-quota-sc 25m10s