All Products
Search
Document Center

Container Service for Kubernetes:Expand a NAS volume

Last Updated:Sep 25, 2023

The Container Storage Interface (CSI) plug-in provided by Container Service for Kubernetes (ACK) allows you to set quotas on the subdirectories of Apsara File Storage NAS (NAS) volumes. You can set quotas to manage resource allocation and improve overall resource utilization. This topic describes how to set quotas on the subdirectories of NAS volumes. This topic also describes how to manually expand NAS volumes.

Prerequisites

  • The image version of csi-plugin is 1.18.8.45 or later. For more information about csi-plugin versions, see csi-plugin.

  • A NAS volume is mounted by using a subdirectory.

Limits

  • Only Capacity NAS file systems support quota limits. For more information about the types of NAS file systems, see NAS file system types.

  • Quotas can be set only for volumes that are mounted by using subdirectories.

  • For each file system, you can create quotas for up to 500 directories.

    • You can set an enforcement quota on a directory. If the quota is exceeded, you cannot write data to the directory and an IOError error occurs at the frontend. The write operations include the operations that are used to increase the length of files, create files, create subdirectories, create special files, and move files to another directory.

    • To prevent potential security risks, we recommend that you evaluate and test restricted quotas before you create the restricted quotas for core business-related directories.

    • The operation of setting quotas for NAS volumes is asynchronous. After you enable or disable an enforcement quota, you need to wait 5 to 15 minutes for the quota to be enabled or disabled.

Example

  1. Use the following YAML template to create a StorageClass to provision a NAS volume that has the quota feature and the dynamic expansion feature enabled.

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: alicloud-nas-quota-sc
    mountOptions:
      - nolock,tcp,noresvport
      - vers=3
    parameters:
      volumeAs: subpath
      server: "xxx.cn-hangzhou.nas.aliyuncs.com:/"
      archiveOnDelete: "false"
      path: "/abc"
      volumeCapacity: "true" # The quota feature is enabled for a volume that is dynamically provisioned based on the StorageClass. 
    provisioner: nasplugin.csi.alibabacloud.com
    reclaimPolicy: Delete
    allowVolumeExpansion: true # Enable dynamic volume expansion. 

    Parameter

    Description

    mountOptions

    Set the mount options of the NAS file system in the mountOptions field. For example, you can specify the NFS version that you want to use.

    volumeAs

    Valid values: subpath or filesystem. To mount a subdirectory to the cluster, set the value to subpath. To mount a file system to the cluster, set the value to filesystem.

    server

    When you mount a subdirectory of the NAS file system as a persistent volume (PV), this parameter specifies the mount target of the NAS file system.

    archiveOnDelete

    This parameter specifies the reclaim policy of backend storage when reclaimPolicy is set to Delete. NAS is a shared storage service. You must set both reclaimPolicy and archiveOnDelete to ensure data security. Default value: true.

    path

    The subdirectory of the NAS file system that is mounted. If you mount an Extreme NAS file system, the path must start with /share.

    volumeCapacity

    This parameter specifies whether to set a quota. Valid values: true and false.

    provisioner

    The provisioner of the PV that is provided by ACK.

    reclaimPolicy

    The policy that is used to reclaim the PV. Valid values:

    • Retain: retains the backend storage when the PV and persistent volume claim (PVC) are deleted. The backend storage may be cloud disks.

    • Delete: automatically deletes the backend storage and PV when the PVC is deleted.

    allowVolumeExpansion

    This parameter specifies whether volume expansion is supported.

    Note

    To create a StorageClass that sets quotas on the subdirectory of a NAS file system, the volumeCapacity parameter must be set to true.

  2. Use the following YAML template to create a StatefulSet. The StatefulSet uses a PVC that requests 20 GiB of storage.

    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: nas-sts
    spec:
      selector:
        matchLabels:
          app: busybox
      serviceName: "busybox"
      replicas: 1
      template:
        metadata:
          labels:
            app: busybox
        spec:
          containers:
          - name: busybox
            image: busybox
            command:
            - sleep
            - "3600"
            volumeMounts:
            - name: nas-pvc
              mountPath: /data
      volumeClaimTemplates:
      - metadata:
          name: nas-pvc
        spec:
          accessModes: [ "ReadWriteMany" ]
          storageClassName: "alicloud-nas-quota-sc"
          resources:
            requests:
              storage: 20Gi

Verify the result

  1. Run the following command to write 10 GiB of data to the /data directory that is mounted to the StatefulSet created in Step 2.

    dd if=/dev/zero of=10G.txt bs=1M count=10000
  2. Wait 5 to 15 minutes and then check the quota details of the subdirectory.

    1. Log on to the NAS console.

    2. In the left-side navigation pane, choose File System > File System List.

    3. Find the NAS file system that you use and click the Icon icon in the Actions column. Then, click Quota Management.

    4. On the Quota Management page, click Manage Quotas in the Actions column.

      The following figure shows that the subdirectory has a quota limit of 20 GiB. The used storage is 9 GiB. image.png

      When the 20 GiB of storage is used up, the Disk quota exceeded error appears if you try to write more data to the subdirectory. Disk quota

  3. If the quota is reached, you can manually perform a dynamic volume expansion.

    1. Run the following command to dynamically expand the volume:

      Note

      Dynamic volume expansion does not interrupt the service that has the volume mounted.

      kubectl patch pvc nas-pvc-0 -p '{"spec":{"resources":{"requests":{"storage":"30Gi"}}}}'
    2. Run the following command to query information about the PV:

      kubectl get pv

      Expected output:

      NAME                              CAPACITY  ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM               STORAGECLASS         REASON     AGE
      nas-63c37cc2-b21e-4b56-b26f-****   30Gi          RWM          Delete        Bound    default/nas-pvc-0   alicloud-nas-quota-sc           25m23s
    3. Run the following command to query information about the PVC:

      kubectl get pvc

      Expected output:

      NAME       STATUS   VOLUME                         CAPACITY  ACCESS MODES   STORAGECLASS            AGE
      nas-pvc-0  Bound   nas-63c37cc2-b21e-4b56-b26f-****   30Gi      RWM        alicloud-nas-quota-sc   25m10s