When many pods share a node and each requires multiple disks—common in database, continuous integration (CI), and batch processing workloads—the default serial mounting increases pod startup time. Disk parallel mounting attaches disks concurrently, reducing startup latency.
Prerequisites
You have an ACK managed cluster running Kubernetes 1.26 or later, with csi-plugin and csi-provisioner both at v1.30.4 or later.
You have installed and configured Alibaba Cloud CLI.
Usage notes
Parallel mounting is supported only for disks that have serial numbers. For more information about how to query the serial number of a disk, see Query serial number.
Disks created before June 10, 2020 do not have recognizable serial numbers. If you enable parallel mounting for these disks, the disks fail to mount.
When multiple disks are unmounted from the same node, the unmount operations still run in serial mode.
After you enable parallel mounting, the
Devicefields returned by the API, such as ECS DescribeDisks, and the mount target displayed in the console may be inaccurate. Do not rely on this mount path in your workloads. Use the serial number of the disk to determine the actual mount path.
Procedure
To enable disk parallel mounting, use either the automated script or the manual procedure below.
Use an automated script
Save the following script as a file named enable_parallel_attach.sh.
Execute the script to mount disks in parallel mode.
bash enable_parallel_attach.sh <Cluster ID>
Manually enable the feature
Add ECS Tags to the node pool of the cluster. Set the tag key to
supportConcurrencyAttachand the tag value totrue. Make sure that the tag is added to a new ECS instance.Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
On the Node Pools page, find the node pool that you want to modify and click Edit in the Actions column.
In the lower part of the page, find the Advanced Options section and add an ECS Tags. Set the key to
supportConcurrencyAttachand the value totrue.
Add a tag to the ECS instances of all existing nodes in the cluster. Set the key to
supportConcurrencyAttachand the value totrue. For more information, see Add a custom tag.In the left-side navigation pane, click Components and Add-ons. Click the Volumes tab, find the
csi-provisioneradd-on, click Configure in the lower-right corner of the component, and set the FeatureGate parameter toDiskADController=true,DiskParallelAttach=true.NoteAfter you specify
DiskADController=true, theattachanddetachoperations related to disks are performed by csi-provisioner. After you specifyDiskParallelAttach=true, the disk parallel mounting feature is enabled.After you configure csi-provisioner, set the FeatureGate parameter of csi-plugin to
DiskADController=true.
Verify disk parallel mounting performance
In this example, pods with a large number of disks mounted are created on the same node to verify pod startup acceleration after parallel mounting is enabled.
The test results in this topic are reference values. Actual results may vary depending on your environment.
Add a node that supports multiple disks to an ACK cluster. For example, an
ecs.g7se.16xlargeinstance supports up to 56 disks.Create a test file named
attach-stress.yamland copy the following content to the file. Replace<YOUR-HOSTNAME>with the node's actual name.Run the following command to confirm that the application starts as expected. Then, scale the replica count to 0 to prepare for the batch mount tests.
kubectl apply -f attach-stress.yaml kubectl rollout status sts attach-stress kubectl scale sts attach-stress --replicas 0Expected output:
storageclass.storage.k8s.io/alibabacloud-disk created statefulset.apps/attach-stress created partitioned roll out complete: 1 new pods have been updated... statefulset.apps/attach-stress scaledRun the following commands to start the batch mount test and measure the pod startup time:
NoteIn this case, parallel mounting is disabled for the cluster. Adjust the number of pods for the test based on the maximum number of disks supported by your node.
date && \ kubectl scale sts attach-stress --replicas 28 && \ kubectl rollout status sts attach-stress && \ dateExpected output:
Tuesday October 15 19:21:36 CST 2024 statefulset.apps/attach-stress scaled Waiting for 28 pods to be ready... Waiting for 27 pods to be ready... <Omitted...> Waiting for 3 pods to be ready... Waiting for 2 pods to be ready... Waiting for 1 pods to be ready... partitioned roll out complete: 28 new pods have been updated... Tuesday October 15 19:24:55 CST 2024The output indicates that more than 3 minutes is required for starting all 28 pods when parallel mounting is disabled.
Enable parallel mounting by following the instructions in the Procedure section.
Run the following command to delete the preceding pods and prepare for the subsequent round of testing:
NoteMonitor the
volumeattachmentsresources in the cluster. After these resources are deleted, the disks are unmounted. This process takes a few minutes.kubectl scale sts attach-stress --replicas 0Run the following command again to calculate the time required for starting pods after parallel mounting is enabled. The expected time is approximately 40 seconds, which is much faster than the 3 minutes when parallel mounting is disabled.
date && \ kubectl scale sts attach-stress --replicas 28 && \ kubectl rollout status sts attach-stress && \ dateExpected output:
Tuesday October 15 20:02:54 CST 2024 statefulset.apps/attach-stress scaled Waiting for 28 pods to be ready... Waiting for 27 pods to be ready... <Omitted...> Waiting for 3 pods to be ready... Waiting for 2 pods to be ready... Waiting for 1 pods to be ready... partitioned roll out complete: 28 new pods have been updated... Tuesday October 15 20:03:31 CST 2024
Run the following command to delete the test applications in the cluster:
kubectl delete -f attach-stress.yaml