Container Service for Kubernetes (ACK) allows you to use the Container Storage Interface (CSI) plug-in to expand a disk volume without service interruptions for clusters that run Kubernetes 1.16 and later. This topic describes how to expand a disk volume without service interruptions.
Usage notes
Data backup
Before you expand a disk volume, create a snapshot for the disk in case data issues occur during disk volume expansion.
Scenarios
You can expand only dynamically provisioned persistent volumes (PVs) without service interruptions, which are mounted by using persistent volume claims (PVCs) that contain the StorageClassName parameter.
You cannot expand disk volumes of the inline type. This type of disk volume is not created by using PVs and PVCs.
You cannot expand volumes that are associated with basic disks without service interruptions.
Specify AllowVolumeExpansion: True for the StorageClass. The AllowVolumeExpansion parameter is automatically set to True for StorageClasses that are created by ACK. For StorageClasses that are manually created, you must manually set the AllowVolumeExpansion parameter to True.
Pods must remain in the Running state during volume expansion.
Plug-in version
Make sure that the CSI plug-in is updated to the latest version.
Grant the ResizeDisk permission to the Resource Access Management (RAM) role of the cluster
Before you expand a disk volume without service interruptions, you must grant the ResizeDisk permission to the RAM role of the cluster. Perform the following steps to grant the ResizeDisk permission based on the cluster type and the volume plug-in that is used:
ACK dedicated clusters that use CSI plug-in
Log on to the ACK console.
In the left-side navigation pane, click Clusters.
On the Clusters page, click Details in the Actions column of the cluster that you want to manage.
In the left-side navigation pane, click Cluster Information.
Click the Cluster Resources tab and click the hyperlink next to Master RAM Role.
In the RAM console, grant the ResizeDisk permission to the RAM role. For more information about how to grant the permissions, see Modify the document and description of a custom policy.
ACK dedicated clusters that use FlexVolume or ACK managed clusters
Perform the preceding Step 1 to Step 4 and click the hyperlink next to Master RAM Role.
Expand a disk volume without starting the application pods
Use a command-line tool to connect to the ACK cluster. For more information, see Step 2: Select a type of cluster credentials.
In this example, the pod that you want to manage is in the following state.
Run the following command to query pod information:
kubectl get pod
Expected output:
<YOUR-POD-NAME> 1/1 Running 0 42s
Run the following command to query the volume that is mounted to the pod:
kubectl exec <YOUR-POD-NAME> -- df /data
Expected output:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/vdb 20511312 45080 20449848 1% /data
Run the following command to query PVC information:
kubectl get pvc
Expected output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE <your-PVC-name> Bound d-wz9hpoifm43yn9zi**** 20Gi RWO alicloud-disk-topology-alltype 57s
Run the following command to query PV information:
kubectl get pv
Expected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE d-wz9hpoifm43yn9zi**** 20Gi RWO Delete Bound default/<your-PVC-name> alicloud-disk-topology-alltype 65s
Run the following command to expand the disk volume when the requirements in the Usage notes section are met:
kubectl patch pvc <your-PVC-name> -p '{"spec":{"resources":{"requests":{"storage":"30Gi"}}}}'
Wait 1 minute and then check whether the PV is expanded.
Run the following command to query PV information:
kubectl get pv d-wz9hpoifm43yn9zi****
Expected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE d-wz9hpoifm43yn9zi**** 30Gi RWO Delete Bound default/<your-PVC-name> alicloud-disk-topology-alltype 5m23s
Run the following command to query PVC information:
kubectl get pvc
Expected output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE <your-PVC-name> Bound d-wz9hpoifm43yn9zi**** 30Gi RWO alicloud-disk-topology-alltype 5m10s
Run the following command to query the volume that is mounted to the pod:
kubectl exec <YOUR-POD-NAME> -- df /data
Expected output:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/vdb 30832548 45036 30771128 1% /data
To expand a disk volume without service interruptions, you need to only run the preceding command.
References
For information about how to automatically expand a disk volume when the utilization of the disk volume exceeds a specified threshold value, see Automatically expand a disk volume (public preview).