All Products
Search
Document Center

Container Service for Kubernetes:Manage the OSS lifecycle

Last Updated:Dec 01, 2026

Container Service for Kubernetes (ACK) uses Container Network File System (CNFS) to independently manage the full lifecycle of OSS buckets. Use CNFS to create or reuse an OSS bucket, configure its storage parameters, and bind the bucket to Deployment and StatefulSet workloads.

Prerequisites

  • The storage plugin is CSI, and the versions of the csi-plugin and csi-provisioner add-ons are v1.24.2-5b34494d-aliyun or later. To upgrade the add-ons, see Upgrade CSI components.

  • The version of the storage-operator add-on is v1.24.95-e2d0756-aliyun or later. To upgrade the add-on, see Manage the storage-operator add-on.

Feature overview

Use CNFS to manage the full lifecycle of OSS in the following two ways:

  • Method 1: Use CNFS to create an OSS bucket named cnfs-oss-

    Use CNFS to create an OSS bucket that is unique to the cluster and provides dynamic OSS PersistentVolume (PV) capabilities. Use CNFS to create an OSS bucket named cnfs-oss-<UUID, such as the cluster ID>, and bind the OSS bucket to the Deployment and StatefulSet workloads by using dynamic volumes.

  • Method 2: Use an existing OSS bucket to create a CNFS

    Create a CNFS CRD and specify BucketName to use an existing OSS bucket. Then use a static or dynamic OSS volume to mount the bucket and bind it to a Deployment.

Note

BucketName: cnfs-oss-<UUID, such as the cluster ID> is described as follows:

  • If BucketName already exists, that bucket is used as the target bucket of the ContainerNetworkFileSystem.

  • If BucketName does not exist, a bucket with the specified name is created, and the ContainerNetworkFileSystem is also created.

    For example, if you specify the name cnfs-oss-<clusterid>, the system creates an OSS bucket named cnfs-oss-<clusterid>, in which <clusterid> is the ID of the ACK cluster, ensuring that BucketName is globally unique.

Method 1: Use CNFS to create an OSS bucket named cnfs-oss-<UUID, such as the cluster ID>

  1. Use CNFS to create an OSS bucket named cnfs-oss-<UUID, such as the cluster ID>, and bind the OSS bucket to the Deployment and StatefulSet workloads by using dynamic volumes.

    Replace <clusterid> with the ID of your cluster.

    # Create the CNFS, StorageClass, Deployment, and StatefulSet objects.
    cat << EOF | kubectl apply -f -
    apiVersion: v1
    kind: Secret
    metadata:
      name: oss-secret
    stringData:
      akId: "xxxx"     #OSS Bucket: The AK/SK pair that is required for mounting.
      akSecret: "xxxx"
    ---
    apiVersion: storage.alibabacloud.com/v1beta1
    kind: ContainerNetworkFileSystem
    metadata:
      name: cnfs-oss-<clusterid>   #The name of the CNFS should be the same as BucketName.
    spec:
      description: "cnfs-oss"
      type: oss
      reclaimPolicy: Retain        #Only the Retain policy is supported. The OSS bucket is not deleted when the CNFS is deleted.
      parameters:
        bucketName: cnfs-oss-<clusterid>  #If the bucket already exists, the bucket information is read. If the bucket does not exist, a bucket named cnfs-oss-clusterid is created. ClusterId must be set to the clusterid of the ACK cluster to ensure that BucketName is globally unique.
        encryptType: "AES256"   #If the bucket already exists, the encryption method of the bucket is changed to AES256. If the bucket does not exist, AES256 is used as the encryption method.
        storageType: "Standard"  #OSS Bucket: Uses the Standard storage class.
        aclType: "private"       #OSS Bucket: Its owner and authorized users have read and write permissions on the files in this bucket.
    ---
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: alibabacloud-cnfs-oss
    parameters:
      containerNetworkFileSystem: cnfs-oss-<clusterid>   #When you create a StorageClass, the bucket information of the CNFS named cnfs-oss-clusterid is used.
      otherOpts: -o max_stat_cache_size=0 -o allow_other #Cache-related operations.
      path: /
      # volumeAs: subpath A subpath is automatically created for each PV under the path directory
      csi.storage.k8s.io/node-publish-secret-name: oss-secret      #Use oss-secret as the Secret for mounting.
      csi.storage.k8s.io/node-publish-secret-namespace: default    #oss-secret: The namespace in which the Secret resides.
    provisioner: ossplugin.csi.alibabacloud.com
    reclaimPolicy: Retain
    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: cnfs-oss-pvc
    spec:
      accessModes:
        - ReadOnlyMany
      storageClassName: alibabacloud-cnfs-oss   #When you create a PVC, the StorageClass named alibabacloud-cnfs-oss is used.
      resources:
        requests:
          storage: 100Gi
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: cnfs-oss-deployment
      labels:
        app: nginx
    spec:
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            volumeMounts:
            - mountPath: "/data"
              name: cnfs-oss-pvc
          volumes:
          - name: cnfs-oss-pvc   #When you create a Deployment, the PVC named cnfs-oss-pvc is used.
            persistentVolumeClaim:
              claimName: cnfs-oss-pvc
    ---
    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: cnfs-oss-sts
      labels:
        app: nginx
    spec:
      serviceName: "nginx"
      replicas: 2
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            volumeMounts:
            - mountPath: "/data"
              name: www
      volumeClaimTemplates:
      - metadata:
          name: www
        spec:
          accessModes: [ "ReadOnlyMany" ]
          storageClassName: "alibabacloud-cnfs-oss"   #When you create a StatefulSet, the PVC named cnfs-oss-pvc is used.
          resources:
            requests:
              storage: 100Gi
    EOF

    CNFS input parameter descriptions:

    Parameter

    Description

    description

    A brief description of the current file system.

    type

    The type of the volume to be created.

    reclaimPolicy

    The reclaim policy. Only the Retain policy is supported. The OSS bucket is not deleted when the CNFS is deleted.

    parameters.bucketName

    The name of the OSS bucket.

    parameters.storageType

    The storage class. Default value: Standard. Valid values:

    • Standard: Standard storage.

    • IA: Infrequent Access.

    • Archive: Archive storage.

    • ColdArchive: Cold Archive storage.

    Note

    Files that use Archive storage or Cold Archive storage cannot be directly read or written. They must be restored before they can be accessed.

    parameters.redundancyType

    The storage redundancy type. Default value: ZRS. Valid values:

    • LRS (locally redundant storage): uses a data redundancy mechanism within a single zone (AZ) to store your data redundantly on multiple devices in multiple facilities within the same zone. Locally redundant storage ensures data durability and availability when hardware fails.

    • ZRS (zone-redundant storage): uses a data redundancy mechanism across multiple zones (AZs) to store your data redundantly in multiple zones within the same region. If a zone becomes unavailable, zone-redundant storage still ensures normal access to your data.

    Important
    • This parameter can be configured only when the storage-operator add-on is v1.26.2-1de13b6-aliyun or later.

    • When ZRS is used, OSS Cold Archive storage and Deep Cold Archive storage cannot be used.

    • For billing information about storageType and redundancyType, see Billable items.

    parameters.encryptType

    The encryption method.

    • None: No encryption.

    • AES256: Uses the AES256 server-side encryption of OSS.

    • SM4: Uses the SM4 server-side encryption of OSS.

    parameters.aclType

    The access permissions (ACL) specified for the bucket. Default value: private. Valid values:

    • public-read-write (public read/write): All users have read and write permissions on the files in the bucket. Use this access permission with caution.

    • public-read (public read): The owner and authorized users of the bucket have read and write permissions on the files in the bucket. Other users have only read permissions on the files in the bucket. Use this access permission with caution.

    • private: The owner and authorized users of the bucket have read and write permissions on the files in the bucket. Other users have no permissions to perform operations on the files in the bucket.

    parameters.enableVersioning

    The versioning state of the bucket. Default value: Enabled. Valid values:

    • Enabled: Versioning is enabled.

    • Suspended: Versioning is suspended.

    • None: Versioning is not enabled.

    Important
    • This parameter can be configured only when the storage-operator add-on is v1.26.2-1de13b6-aliyun or later.

    • Bucket versioning cannot be configured at the same time as a compliance retention policy or the OSS-HDFS service. If you plan to enable these two services later, set enableVersioning to None.

    • If the bucket is in the Enabled state with versioning enabled, it cannot be returned to the None state with versioning disabled. Versioning can be suspended instead of disabled when the bucket is in the Enabled state.

    • The versioning feature itself is free, but storage fees are charged for the files of the current version and all previous versions. Configure lifecycle rules to reclaim previous versions. For more information, see Lifecycle.

  2. View the OSS bucket that was created.

    kubectl get cnfs/cnfs-oss-<clusterid> -o yaml

    Expected output:

    apiVersion: storage.alibabacloud.com/v1beta1
    kind: ContainerNetworkFileSystem
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"storage.alibabacloud.com/v1beta1","kind":"ContainerNetworkFileSystem","metadata":{"annotations":{},"name":"cnfs-oss-xxxxxxxxxx"},"spec":{"description":"cnfs-oss","parameters":{"aclType":"private","bucketName":"cnfs-oss-clusterid","encryptType":"AES256","storageType":"Standard"},"reclaimPolicy":"Retain","type":"oss"}}
      creationTimestamp: "2022-09-18T07:02:34Z"
      finalizers:
      - protection.alibabacloud.com/cnfs
      generation: 6
      name: cnfs-oss-****
      resourceVersion: "8091291"
      uid: ca187b2a-3bfa-4a5f-82d8-ca1b1f69****
    spec:
      description: cnfs-oss
      parameters:
        aclType: private
        bucketName: cnfs-oss-****
        encryptType: AES256
        storageType: Standard
      reclaimPolicy: Retain
      type: oss
    status:
      conditions:
      - lastProbeTime: "2022-09-18 15:02:39"
        reason: The oss bucket is complete initialization.
        status: Ready
      fsAttributes:
        accessGroupName: DEFAULT_VPC_GROUP_NAME
        aclType: private
        bucketName: cnfs-oss-****
        encryptType: AES256
        endPoint:
          extranet: oss-****.aliyuncs.com
          internal: oss-****-internal.aliyuncs.com
        regionId: ****
        storageType: Standard
      status: Available

    CNFS output parameter descriptions:

    Parameter

    Description

    status

    The current state of the CNFS, which includes the following states:

    • Pending: Waiting.

    • Creating: The CNFS is being created.

    • Initialization: The file system is being created.

    • Available: The CNFS is available.

    • Unavailable: The CNFS is temporarily unavailable and can be restored to the available state.

    • Fatal: The CNFS is unavailable and cannot be restored.

    • Terminating: The CNFS is being deleted.

    conditions.lastProbeTime

    The time of the last liveness probe.

    conditions.reason

    The reason why the CNFS is in the current state.

    conditions.status

    Indicates whether the current state is available.

    • Ready: The available state.

    • NotReady: The unavailable state.

    fsAttributes.accessGroupName

    The name of the permission group that is applied to the mount target. Only DEFAULT_VPC_GROUP_NAME (the default permission group of the VPC) is supported.

    fsAttributes.encryptType

    The encryption method.

    • None: No encryption.

    • AES256: Uses the AES256 server-side encryption of OSS.

    • SM4: Uses the SM4 server-side encryption of OSS.

    fsAttributes.regionId

    The region in which the ACK cluster is deployed.

    fsAttributes.storageType

    The storage class. Default value: Standard.

    • Standard: Standard storage.

    • IA: Infrequent Access.

    • Archive: Archive storage.

    • ColdArchive: Cold Archive storage.

    Note

    Files that use Archive storage or Cold Archive storage cannot be directly read or written. They must be restored before they can be accessed.

    fsAttributes.redundancyType

    The storage redundancy type. Default value: ZRS. Valid values:

    • LRS (locally redundant storage): uses a data redundancy mechanism within a single zone (AZ) to store your data redundantly on multiple devices in multiple facilities within the same zone. Locally redundant storage ensures data durability and availability when hardware fails.

    • ZRS (zone-redundant storage): uses a data redundancy mechanism across multiple zones (AZs) to store your data redundantly in multiple zones within the same region. If a zone becomes unavailable, zone-redundant storage still ensures normal access to your data.

    Important
    • This parameter can be configured only when the storage-operator add-on is v1.26.2-1de13b6-aliyun or later.

    • When ZRS is used, OSS Cold Archive storage and Deep Cold Archive storage cannot be used.

    • For billing information about storageType and redundancyType, see Billable items.

    fsAttributes.aclType

    The access permissions (ACL) specified by CNFS for the bucket. Default value: private.

    fsAttributes.endPoint

    The endpoint of the CNFS.

    • extranet: The public endpoint.

    • internal: The internal endpoint.

    fsAttributes.enableVersioning

    The versioning state of the bucket. Default value: Enabled. Valid values:

    • Enabled: Versioning is enabled.

    • Suspended: Versioning is suspended.

    • None: Versioning is not enabled.

    Important
    • This parameter can be configured only when the storage-operator add-on is v1.26.2-1de13b6-aliyun or later.

    • Bucket versioning cannot be configured at the same time as a compliance retention policy or the OSS-HDFS service. If you plan to enable these two services later, set enableVersioning to None.

    • If the bucket is in the Enabled state with versioning enabled, it cannot be returned to the None state with versioning disabled. Versioning can be suspended instead of disabled when the bucket is in the Enabled state.

    • The versioning feature itself is free, but storage fees are charged for the files of the current version and all previous versions. Configure lifecycle rules to reclaim previous versions. For more information, see Lifecycle.

  3. View the status of the applications that were created.

    kubectl get pod

    Expected output:

    NAME                                   READY   STATUS    RESTARTS   AGE
    cnfs-oss-deployment-5864fd8d98-4****   1/1     Running   0          2m21s
    cnfs-oss-sts-0                         1/1     Running   0          2m21s
    cnfs-oss-sts-1                         1/1     Running   0          2m16s

    The expected output shows that the created Deployment and StatefulSet are in the Running state, which indicates that the Deployment is using CNFS as expected.

Method 2: Use an existing OSS bucket to create a CNFS

Create a CNFS CRD and specify BucketName to use an existing OSS bucket. Then use a static or dynamic OSS volume to mount the bucket and bind it to a Deployment.

  1. Use an existing OSS bucket to create a CNFS.

    cat <<EOF | kubectl apply -f -
    apiVersion: storage.alibabacloud.com/v1beta1
    kind: ContainerNetworkFileSystem
    metadata:
      name: cnfs-oss-exist-bucket-name
    spec:
      description: "cnfs-oss"
      type: oss
      reclaimPolicy: Retain
      parameters:
        bucketName: bucket-name #The name of the existing OSS bucket.
    EOF
  2. View the details of the OSS bucket.

    kubectl get cnfs/cnfs-oss-exist-bucket-name -o yaml

    Expected output:

    apiVersion: storage.alibabacloud.com/v1beta1
    kind: ContainerNetworkFileSystem
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"storage.alibabacloud.com/v1beta1","kind":"ContainerNetworkFileSystem","metadata":{"annotations":{},"name":"cnfs-oss-xxxx"},"spec":{"description":"cnfs-oss","parameters":{"bucketName":"exist-bucket-name"},"reclaimPolicy":"Retain","type":"oss"}}
      creationTimestamp: "2022-09-14T09:21:10Z"
      finalizers:
      - protection.alibabacloud.com/cnfs
      generation: 7
      name: cnfs-oss-exist-bucket-name
      resourceVersion: "6504134"
      uid: 921564ac-0cd8-4a89-997d-c2393afd****
    spec:
      description: cnfs-oss
      parameters:
        bucketName: exist-bucket-name
      reclaimPolicy: Retain
      type: oss
    status:
      conditions:
      - lastProbeTime: "2022-09-14 17:00:21"
        reason: The oss bucket is complete initialization.
        status: Ready
      fsAttributes:
        accessGroupName: DEFAULT_VPC_GROUP_NAME
        aclType: private
        bucketName: exist-bucket-name
        encryptType: AES256
        endPoint:
          extranet: oss-****.aliyuncs.com           
          internal: oss-****-internal.aliyuncs.com
        regionId: ****
        storageType: Standard
      status: Available
  3. Apply CNFS in an OSS volume.

    For instructions, see Method 1: Use CNFS to create an OSS bucket named cnfs-oss-, and apply CNFS by using dynamic volumes.