In containerized scenarios, traditional FUSE-based file systems (such as ossfs) are often used to mount object storage data. For small-file read-intensive workloads—such as AI training dataset loading or time-series log analysis that must quickly traverse millions of small files—traditional approaches struggle to meet high throughput and low latency requirements. We recommend using virtual block devices: mount object storage data directly via strmvol volumes to optimize small-file read performance.
Usage notes
strmvol volumes
-
Only internal endpoints can be used to access OSS data.
-
During initialization, the virtual block device builds a file metadata index. This consumes node resources and keeps the pod in
ContainerCreatingstate. Time and resources scale with the file count in the mount path.-
When you select an OSS bucket mount path, follow the principle of least privilege.
If Business A accesses
/app/a/and Business B accesses/app/b/in the same bucket, create separate volumes with mount paths/app/a/and/app/b/. -
For initialization overhead, see Metadata index construction.
-
-
PV settings limit virtual block device resource consumption during its mount lifecycle (excluding initialization). Reserve sufficient node resources.
-
Each virtual block device has a 16 TiB capacity, limiting the mounted OSS path to 16 TiB of data.
Cluster and node requirements
-
The cluster must be an ACK managed Pro cluster or an ACK dedicated cluster that runs Kubernetes 1.20 or later. The storage plug-in must be a Container Storage Interface (CSI) plug-in.
-
Nodes require kernel 4.19 or later. Recommended: at least 4 vCPU and 8 GiB memory.
-
Supported operating systems: Alibaba Cloud Linux 3, Alibaba Cloud Linux 2, and CentOS 7. For optimal data access performance with the erofs operating system, use Alibaba Cloud Linux 3.
NoteCentOS 7 and Alibaba Cloud Linux 2 have reached end of life (EOL). See [Product Change] Announcement on the Discontinuation of Support for Alibaba Cloud Linux 2 and CentOS 7.
-
You cannot mount strmvol volumes to serverless pods on virtual nodes.
Prerequisites
Step 1: Deploy the strmvol-csi-driver
The strmvol-csi-driver runs independently from the ACK-managed csi-provisioner and csi-plugin.
-
Log on to the ACK console. In the left-side navigation pane, choose .
-
On the Marketplace page, search for strmvol-csi-driver and click its card.
-
On the application details page, click Deploy.
-
In the panel that appears, configure the settings and click OK.
Step 2: Configure OSS access permissions
-
Create a RAM user and grant the required permissions.
Create a RAM user. You can skip this step if you already have a RAM user.
Go to the Create User page on the RAM Console and follow the on-screen instructions to create a RAM user. You must specify parameters such as the logon name and password.
-
Create a custom policy for OSS access.
Select a read-only or read-write policy and replace
mybucketwith your bucket name.-
OSS read-only policy
-
OSS read/write policy
Click to view the read/write policy
{ "Statement": [ { "Action": "oss:*", "Effect": "Allow", "Resource": [ "acs:oss:*:*:mybucket", "acs:oss:*:*:mybucket/*" ] } ], "Version": "1" }
-
-
(Optional) If you encrypt OSS objects with a customer master key (CMK) from Key Management Service (KMS), also grant the RAM user KMS permissions. See Encrypt ossfs 1.0 volumes.
-
Grant OSS permissions to the RAM user. See Manage RAM user permissions.
The AccessKey you create will be stored as a Secret for the PV.
Go to the Users page on the RAM Console, click the name of your RAM user, and then in the AccessKey section, click Create AccessKey.
Follow the on-screen instructions to create an AccessKey. Copy and securely store the AccessKey ID and AccessKey Secret.
-
Create a secret to store the OSS access credentials.
Replace
akIdandakSecretwith your AccessKey ID and AccessKey Secret.kubectl create -n default secret generic strmvol-secret --from-literal='akId=xxxxxx' --from-literal='akSecret=xxxxxx'
Mount a strmvol volume
Step 1: Create a strmvol volume
Static volume
-
Create a PersistentVolume (PV).
-
Create a file named strmvol-pv.yaml.
apiVersion: v1 kind: PersistentVolume metadata: name: pv-strmvol spec: capacity: # The mounted OSS path can store a maximum of 16 TiB of data. storage: 20Gi # Only the ReadOnlyMany access mode is supported. accessModes: - ReadOnlyMany # To prevent accidental data loss, only the Retain policy is supported. persistentVolumeReclaimPolicy: Retain csi: driver: strmvolplugin.csi.alibabacloud.com volumeHandle: pv-strmvol # Use the secret created in the prerequisite steps. nodeStageSecretRef: name: strmvol-secret namespace: default volumeAttributes: bucket: cnfs-oss-test path: /subpath # strmvol volumes only support accessing OSS data over an internal network. url: oss-cn-hangzhou-internal.aliyuncs.com umask: "000" directMode: "false" resourceLimit: "2c4g"-
Parameters in
nodeStageSecretRefParameter
Required
Description
nameYes
The secret name for the AccessKey.
namespaceYes
The namespace of the AccessKey secret.
-
Parameters in
volumeAttributesParameter
Required
Description
bucketYes
The OSS bucket to mount.
pathNo
The directory path within the OSS bucket, relative to the bucket root.
ImportantSelect a mount path based on the principle of least privilege.
urlYes
The OSS internal endpoint. Must match the endpoint on the bucket Overview page in the OSS console. Common formats:
http://oss-{{regionName}}-internal.aliyuncs.comorhttps://oss-{{regionName}}-internal.aliyuncs.com.ImportantThe
vpc100-oss-{{regionName}}.aliyuncs.comformat is deprecated. Update to a supported format.umaskNo
The permission mask for the file system after the virtual block device is mounted.
For example, set
umaskto022for755file permissions.directModeNo
Specifies whether to enable direct mode.
-
"true": Enables direct mode, disabling data prefetching and local caching. Suitable for random read scenarios such as batch reading of training datasets. -
"false": Disables direct mode (default). Suitable for general-purpose scenarios such as sequential small file reads or large file reads. Use this if your application has no specific access pattern.
resourceLimitNo
The maximum node resources that the virtual block device can consume.
For example,
"2c4g"means up to 2 vCPUs and 4 GiB of memory.Note-
Memory is used for data prefetching and caching. In direct mode, memory usage is much lower than the preset value.
-
For non-Alibaba Cloud Linux 3 systems, read performance varies little by configuration. High resource limits are not recommended. See Data read performance tests.
-
-
-
Create the PV.
kubectl create -f strmvol-pv.yaml -
Check the status of the PV.
kubectl get pv pv-strmvolExpected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE pv-strmvol 20Gi ROX Retain Available <unset> 18s
-
-
Create a PersistentVolumeClaim (PVC).
-
Create a file named strmvol-pvc-static.yaml.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: pvc-strmvol namespace: default spec: # The following settings must match the PV configuration. accessModes: - ReadOnlyMany resources: requests: storage: 20Gi volumeName: pv-strmvol -
Create the PVC.
kubectl create -f strmvol-pvc-static.yaml -
Check the status of the PVC.
kubectl get pvc pvc-strmvolThe output shows the PVC is bound to the PV.
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE pvc-strmvol-2 Bound pv-strmvol 20Gi ROX <unset> 16s
-
Dynamic volume
-
Create a StorageClass.
-
Create a file named strmvol-sc.yaml.
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: strmvol-test parameters: # Use the secret created in the prerequisite steps. csi.storage.k8s.io/node-stage-secret-name: strmvol-secret csi.storage.k8s.io/node-stage-secret-namespace: default bucket: cnfs-oss-test path: /subpath # strmvol volumes only support accessing OSS data over an internal network. url: oss-cn-hangzhou-internal.aliyuncs.com umask: "000" directMode: "false" resourceLimit: "2c4g" provisioner: strmvolplugin.csi.alibabacloud.com # To prevent accidental data loss, only the Retain policy is supported. reclaimPolicy: Retain volumeBindingMode: Immediateparametersfields:-
Secret configuration
Parameter
Required
Description
csi.storage.k8s.io/node-stage-secret-nameYes
The secret name for the AccessKey.
csi.storage.k8s.io/node-stage-secret-namespaceYes
The namespace of the AccessKey secret.
-
Volume configuration
Parameter
Required
Description
bucketYes
The OSS bucket to mount.
pathNo
The directory path within the OSS bucket, relative to the bucket root.
ImportantSelect a mount path based on the principle of least privilege.
urlYes
The OSS internal endpoint. Must match the endpoint on the bucket Overview page in the OSS console. Common formats:
http://oss-{{regionName}}-internal.aliyuncs.comorhttps://oss-{{regionName}}-internal.aliyuncs.com.ImportantThe
vpc100-oss-{{regionName}}.aliyuncs.comformat is deprecated. Update to a supported format.umaskNo
The permission mask for the file system after the virtual block device is mounted.
For example, set
umaskto022for755file permissions.directModeNo
Specifies whether to enable direct mode.
-
"true": Enables direct mode, disabling data prefetching and local caching. Suitable for random read scenarios such as batch reading of training datasets. -
"false": Disables direct mode (default). Suitable for general-purpose scenarios such as sequential small file reads or large file reads. Use this if your application has no specific access pattern.
resourceLimitNo
The maximum node resources that the virtual block device can consume.
For example,
"2c4g"means up to 2 vCPUs and 4 GiB of memory.Note-
Memory is used for data prefetching and caching. In direct mode, memory usage is much lower than the preset value.
-
For non-Alibaba Cloud Linux 3 systems, read performance varies little by configuration. High resource limits are not recommended. See Data read performance tests.
-
-
-
Create the StorageClass.
kubectl create -f strmvol-sc.yaml
-
-
Create a PVC.
-
Create a file named strmvol-pvc-dynamic.yaml.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: pvc-strmvol namespace: default spec: # Only the ReadOnlyMany access mode is supported. accessModes: - ReadOnlyMany # Specify the StorageClass. storageClassName: strmvol-test resources: requests: # The mounted OSS path can store a maximum of 16 TiB of data. storage: 20Gi -
Create the PVC.
kubectl create -f strmvol-pvc-dynamic.yaml -
Check the status of the PVC.
kubectl get pvc pvc-strmvolThe output shows the PVC bound to an automatically provisioned PV.
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE pvc-strmvol Bound strmvol-d8d1d22a-e1d7-4caa-b875-54f378dec769 20Gi ROX strmvol-test <unset> 3m
-
Step 2: Create an application and mount the volume
-
Create a file named strmvol-test.yaml.
This StatefulSet creates one pod that uses the
pvc-strmvolPVC, mounted at/data.apiVersion: apps/v1 kind: StatefulSet metadata: name: strmvol-test namespace: default spec: replicas: 1 selector: matchLabels: app: strmvol-test template: metadata: labels: app: strmvol-test spec: containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 ports: - containerPort: 80 volumeMounts: - name: pvc-strmvol mountPath: /data volumes: - name: pvc-strmvol persistentVolumeClaim: claimName: pvc-strmvol -
Create the StatefulSet.
kubectl create -f strmvol-test.yaml -
Check the pod status.
kubectl get pod -l app=strmvol-testExpected output:
NAME READY STATUS RESTARTS AGE strmvol-test-0 1/1 Running 0 14s -
Verify the mount point is a block device and OSS data is accessible.
kubectl exec -it strmvol-test-0 -- sh -c "df /data && ls /data"Expected output:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/ublkb1 24812 24812 0 100% /data <data in OSS mount path>