All Products
Search
Document Center

Container Service for Kubernetes:Optimize OSS small file reads with strmvol volumes

Last Updated:Oct 21, 2026

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 ContainerCreating state. 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.

    Note

    CentOS 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.

  1. Log on to the ACK console. In the left-side navigation pane, choose Marketplace > Marketplace.

  2. On the Marketplace page, search for strmvol-csi-driver and click its card.

  3. On the application details page, click Deploy.

  4. In the panel that appears, configure the settings and click OK.

Step 2: Configure OSS access permissions

  1. Create a RAM user and grant the required permissions.

    1. 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.

    2. Create a custom policy for OSS access.

      Select a read-only or read-write policy and replace mybucket with your bucket name.

      • OSS read-only policy

        Click to view the read-only policy

        {
            "Statement": [
                {
                    "Action": [
                        "oss:Get*",
                        "oss:List*"
                    ],
                    "Effect": "Allow",
                    "Resource": [
                        "acs:oss:*:*:mybucket",
                        "acs:oss:*:*:mybucket/*"
                    ]
                }
            ],
            "Version": "1"
        }
      • 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"
        }
    3. (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.

    4. Grant OSS permissions to the RAM user. See Manage RAM user permissions.

    5. The AccessKey you create will be stored as a Secret for the PV.

      1. 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.

      2. Follow the on-screen instructions to create an AccessKey. Copy and securely store the AccessKey ID and AccessKey Secret.

  2. Create a secret to store the OSS access credentials.

    Replace akId and akSecret with 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

  1. Create a PersistentVolume (PV).

    1. 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 nodeStageSecretRef

        Parameter

        Required

        Description

        name

        Yes

        The secret name for the AccessKey.

        namespace

        Yes

        The namespace of the AccessKey secret.

      • Parameters in volumeAttributes

        Parameter

        Required

        Description

        bucket

        Yes

        The OSS bucket to mount.

        path

        No

        The directory path within the OSS bucket, relative to the bucket root.

        Important

        Select a mount path based on the principle of least privilege.

        url

        Yes

        The OSS internal endpoint. Must match the endpoint on the bucket Overview page in the OSS console. Common formats:

        http://oss-{{regionName}}-internal.aliyuncs.com or https://oss-{{regionName}}-internal.aliyuncs.com.

        Important

        The vpc100-oss-{{regionName}}.aliyuncs.com format is deprecated. Update to a supported format.

        umask

        No

        The permission mask for the file system after the virtual block device is mounted.

        For example, set umask to 022 for 755 file permissions.

        directMode

        No

        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.

        resourceLimit

        No

        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.

    2. Create the PV.

      kubectl create -f strmvol-pv.yaml
    3. Check the status of the PV.

      kubectl get pv pv-strmvol

      Expected output:

      NAME         CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   VOLUMEATTRIBUTESCLASS   REASON   AGE
      pv-strmvol   20Gi       ROX            Retain           Available                          <unset>                          18s
  2. Create a PersistentVolumeClaim (PVC).

    1. 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
    2. Create the PVC.

      kubectl create -f strmvol-pvc-static.yaml
    3. Check the status of the PVC.

      kubectl get pvc pvc-strmvol

      The 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

  1. Create a StorageClass.

    1. 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: Immediate

      parameters fields:

      • Secret configuration

        Parameter

        Required

        Description

        csi.storage.k8s.io/node-stage-secret-name

        Yes

        The secret name for the AccessKey.

        csi.storage.k8s.io/node-stage-secret-namespace

        Yes

        The namespace of the AccessKey secret.

      • Volume configuration

        Parameter

        Required

        Description

        bucket

        Yes

        The OSS bucket to mount.

        path

        No

        The directory path within the OSS bucket, relative to the bucket root.

        Important

        Select a mount path based on the principle of least privilege.

        url

        Yes

        The OSS internal endpoint. Must match the endpoint on the bucket Overview page in the OSS console. Common formats:

        http://oss-{{regionName}}-internal.aliyuncs.com or https://oss-{{regionName}}-internal.aliyuncs.com.

        Important

        The vpc100-oss-{{regionName}}.aliyuncs.com format is deprecated. Update to a supported format.

        umask

        No

        The permission mask for the file system after the virtual block device is mounted.

        For example, set umask to 022 for 755 file permissions.

        directMode

        No

        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.

        resourceLimit

        No

        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.

    2. Create the StorageClass.

      kubectl create -f strmvol-sc.yaml
  2. Create a PVC.

    1. 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
    2. Create the PVC.

      kubectl create -f strmvol-pvc-dynamic.yaml
    3. Check the status of the PVC.

      kubectl get pvc pvc-strmvol

      The 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

  1. Create a file named strmvol-test.yaml.

    This StatefulSet creates one pod that uses the pvc-strmvol PVC, 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
  2. Create the StatefulSet.

    kubectl create -f strmvol-test.yaml
  3. Check the pod status.

    kubectl get pod -l app=strmvol-test

    Expected output:

    NAME             READY   STATUS    RESTARTS   AGE
    strmvol-test-0   1/1     Running   0          14s
  4. 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>

Related documentation

strmvol client performance tests