All Products
Search
Document Center

Elastic Container Instance:Create and manage a DataCache

Last Updated:Jun 20, 2026

After you deploy the DataCache Custom Resource Definition (CRD), you can create a DataCache to pre-pull data required by your workloads, such as AI training models. This topic describes the configuration parameters for a DataCache and how to create, query, and delete a DataCache.

Prerequisites

The DataCache CRD must be deployed in your cluster. For more information, see Deploy a DataCache CRD.

Create a DataCache

Parameters

The following YAML file shows the configuration parameters for a DataCache:

apiVersion: eci.aliyun.com/v1alpha1
kind: DataCache
metadata:
  name: test-url
spec:
  bucket: default
  path: /demo/url
  size: 20
  retentionDays: 3
  dataSource:
    type: URL 
    options:
      url: https://www.example.com
  netConfig: 
    securityGroupId: sg-2ze63v3jtm8e6sy******
    vSwitchId: vsw-2ze94pjtfuj9vaym******

The parameters are as follows:

  • apiVersion: The API version. The value must be eci.aliyun.com/v1alpha1.

  • kind: The resource type. The value must be DataCache.

  • metadata

    • name: The name of the DataCache.

  • spec

    • bucket: The bucket for storing the data. The default value is default. You can customize this value. Do not use eci-system, which is reserved for Elastic Container Instance (ECI).

    • path: The path where the data is stored.

    • size: The size of the DataCache in GiB. The default value is 20 GiB. Estimate the required size based on your actual data volume.

    • retentionDays: The number of days to retain the DataCache. The system automatically deletes expired DataCaches. By default, DataCaches are retained indefinitely.

    • dataSource: The data source, which includes the data source type and configuration options.

      Type

      Description

      Parameter

      URL

      URL

      • url: The URL from which to download the data.

      • accessToken: Configure this parameter to authenticate when you pull private data.

      HuggingFace or ModelScope

      • repoSource: The source repository. Valid values are ModelScope/Model, ModelScope/DataSet, HuggingFace/Model, and HuggingFace/DataSet. Specifies whether to pull a model or a dataset from ModelScope or HuggingFace.

      • repoId: The ID of the model or dataset.

      • revision: The version. The default value is main or master.

      • accessToken: Configure this parameter to authenticate when you pull private data.

      NAS

      NAS file system

      • server: The mount target of the NAS file system.

      • path: The subdirectory to mount. For Extreme NAS file systems, the path must start with /share, for example, /share/path.

      • vers: The NFS protocol version for mounting the NAS file system. We recommend v3. Extreme NAS file systems support only v3.

      • options: The mount options. We recommend using the options suggested by the File Storage NAS service, such as nolock,tcp,noresvport.

      OSS

      OSS bucket

      • bucket: The name of the OSS bucket.

      • url: The OSS endpoint.

      • path: The subdirectory to mount relative to the bucket root. The default value is /.

      • otherOpts: Custom parameters for mounting OSS. The format is -o *** -o ***, for example, -o max_stat_cache_size=0 -o allow_other.

      • ramRole: The RAM role to use for authorization.

        Note

        You must create a RAM role and grant permissions to it. For more information, see Create a RAM role for a trusted Alibaba Cloud service and Grant permissions to a RAM role.

        When you create the role, set the Trusted Entity Type to Alibaba Cloud Service, the Role Type to Normal Service Role, and the Trusted Service to Elastic Compute Service. When you grant permissions to the role, select the AliyunOSSFullAccess policy.

      • akId: The AccessKey ID to use for direct authorization. For more information, see Obtain an AccessKey pair.

      • akSecret: The AccessKey Secret to use for direct authorization. For more information, see Obtain an AccessKey pair.

      SNAPSHOT

      snapshot

      snapshotId: The ID of the snapshot.

    • netConfig

      • securityGroupId: The security group ID for the ECI instance that generates the DataCache.

      • vSwitchId: The vSwitch ID for the ECI instance that generates the DataCache.

      To pull data over the internet on a vSwitch without a configured SNAT gateway, you can bind an EIP. To do this, add the EIP-related parameters under netConfig.

      netConfig: 
        eipInstanceId: eip-2zey74a7zienoxf*****  # Choose one: eipInstanceId or eipCreateParam
        eipCreateParam:  # Choose one: eipInstanceId or eipCreateParam
          bandwidth: 5
          commonBandwidthPackage:  cbwp-2zeukbj916scmj5******
          internetChargeType:  PayByTraffic
          publicIpAddressPoolId: pippool-bp187arfugi543y1s****
          ISP: BGP
      • eipInstanceId: The ID of an existing EIP to bind for pulling data from the internet. Use this parameter if the vSwitch does not have a configured SNAT gateway.

      • eipCreateParam: Parameters to create and bind a new EIP. Use these if the specified vSwitch has no configured SNAT gateway and no existing EIP is available.

        • bandwidth: The bandwidth of the EIP. Unit: Mbit/s. The default value is 5 Mbit/s.

        • commonBandwidthPackage: The ID of an existing Internet Shared Bandwidth instance to associate with the EIP. For more information, see Internet Shared Bandwidth.

        • internetChargeType: The billing method of the EIP. Valid values: PayByBandwidth and PayByTraffic. For more information, see EIP billing methods.

        • publicIpAddressPoolId: The ID of the IP address pool from which the EIP is allocated. The IP address pool feature is not enabled by default. To use this feature, you must apply for the required quota in Quota Center. For more information, see IP address pools.

        • ISP: The line type of the EIP. Valid values: BGP (default) and BGP_PRO. For more information, see EIP line types.

Configuration examples

Create a YAML file for the DataCache (for example, datacache.yaml), and then run a kubectl command to create the DataCache.

  • Create a DataCache

    kubectl create -f datacache.yaml
  • Update a DataCache

    kubectl apply -f datacache.yaml

URL

  • Pull data from a URL

    apiVersion: eci.aliyun.com/v1alpha1
    kind: DataCache
    metadata:
      name: test-url-1
    spec:
      path: /demo/url
      dataSource:
        type: URL 
        options:
          url: https://www.example.com
      netConfig:                
        securityGroupId: sg-2ze63v3jtm8e6sy******
        vSwitchId: vsw-2ze94pjtfuj9vaym******
  • Pull a model from HuggingFace

    apiVersion: eci.aliyun.com/v1alpha1
    kind: DataCache
    metadata:
      name: test-url-2
    spec:
      path: /demo/url
      dataSource:
        type: URL 
        options:
          repoSource: "HuggingFace/Model"        
          repoId: "decapoda-research/llama-7b-hf"
      netConfig: 
        securityGroupId: sg-2ze63v3jtm8e6sy******
        vSwitchId: vsw-2ze94pjtfuj9vaym******

NAS

apiVersion: eci.aliyun.com/v1alpha1
kind: DataCache
metadata:
  name: test-nas
spec:
  path: /demo/nas
  dataSource:
    type: NAS 
    options:
      server: "0389a***-nh**.cn-beijing.extreme.nas.aliyuncs.com"
      path: "/"
      vers: "3"
      options: "nolock,tcp,noresvport"
  netConfig: 
    securityGroupId: sg-2ze63v3jtm8e6sy******
    vSwitchId: vsw-2ze94pjtfuj9vaym******

OSS

apiVersion: eci.aliyun.com/v1alpha1
kind: DataCache
metadata:
  name: test-oss
spec:
  path: /demo/oss
  dataSource:
    type: OSS 
    options:
      bucket: "oss-***"
      url: "oss-cn-beijing-internal.aliyuncs.com"
      path: "/test"
      otherOpts: "-o max_stat_cache_size=0 -o allow_other"
      ramRole: "<your RAM Role Name>"
  netConfig: 
    securityGroupId: sg-2ze63v3jtm8e6sy******
    vSwitchId: vsw-2ze94pjtfuj9vaym******

Snapshot

apiVersion: eci.aliyun.com/v1alpha1
kind: DataCache
metadata:
  name: test-snapshot
spec:
  path: /demo/snapshot
  dataSource:
    type: SNAPSHOT 
    options:
      snapshotId: s-uf6j98q2tvfcjz******
  netConfig: 
    securityGroupId: sg-2ze63v3jtm8e6sy******
    vSwitchId: vsw-2ze94pjtfuj9vaym***

Manage DataCaches

Note

When you query or delete a DataCache, you can use any of the following names as the resource type name:

  • edc

  • datacache

  • datacaches

  • datacaches.eci.aliyun.com

Query a DataCache

After you create a DataCache, you can list all DataCaches in the cluster or view the details of a specific one.

  • List all DataCaches in the cluster

    kubectl get edc 

    The following is sample output. A status of Available indicates that the DataCache is ready to use.

    ~$ kubectl get datacache
    NAME              AGE   DATACACHEID            STATUS      PROGRESS   BUCKET    PATH
    test-snapshot     3m5s  edc-2zef0yo3be9g8…     Creating    27%        default   /demo/snapshot
    test-url-2        81m   edc-2zehgoxuevp3er     Available   100%       default   /demo/url
  • View the details of a specific DataCache

    kubectl describe edc <edc-name>

    The following sample response includes the DataCache's basic information, metadata, configuration, status, and events.

    :~$ kubectl describe edc test-url-2
    Name:         test-url-2
    Namespace:
    Labels:       <none>
    Annotations:  <none>
    API Version:  eci.aliyun.com/v1alpha1
    Kind:         DataCache
    Metadata:
      Creation Timestamp:  2023-07-27T08:25:26Z
      Finalizers:
        eci.aliyun.com/datacachecontroller
      Generation:        1
      Resource Version:  816839
      UID:               70b90647-4915-45d5-a075-f0e3cf2fdcfb
    Spec:
      Bucket:  default
      Data Source:
        Options:
          Repo Id:      decapoda-research/llama-7b-hf
          Repo Source:  HuggingFace/Model
          Type:         URL
      Net Config:
        Security Group Id:  sg-2zegwszw5xxx
        V Switch Id:        vsw-2zeet2ksxxx
      Path:                 /demo/url
      Size:                 20
    Status:
      Data Cache Id:  edc-2zehgoxuevpxxx
      Progress:       100%
      Snapshot Id:    s-2zeib05j5bmxm:xxx
      Status:         Available
    Events:
      Type    Reason    Age   From                  Message
      ----    ------    ----  ----                  -------
      Normal  Creating  31m   datacache-controller  Creating dataCache in ECI
      Normal  Creating  31m   datacache-controller  ECI status: Pending
      Normal  Success   30m   datacache-controller  Create dataCache in ECI successfully

Delete a DataCache

Important

Each DataCache corresponds to a snapshot, which incurs storage costs. To avoid unnecessary charges, promptly delete DataCaches that you no longer need.

To delete a DataCache, run the following command:

kubectl delete edc <edc-name>