All Products
Search
Document Center

Create an elastic container instance that has local disks attached

Last Updated: May 24, 2021

This topic describes how to create and use an elastic container instance that has local disks attached.

Background information

You can specify Elastic Compute Service (ECS) instance types equipped with local disks to create elastic container instances that have local disks attached. Local disks are physically located on the same physical servers as the elastic container instances to which the disks are attached. Local disks are cost-effective and provide high random IOPS, high throughput, and low latency. Local disks reside on single physical servers, which increases the risks of single points of failure (SPOFs). For more information, see Local disks.

The following ECS instance families equipped with local disks are supported:

  • d1, big data instance family that includes a variety of instance types such as ecs.d1.2xlarge

  • d1ne, big data instance family with enhanced network performance, which includes a variety of instance types such as ecs.d1ne.2xlarge

  • i2, instance family equipped with local SSDs, which includes a variety of instance types such as ecs.i2.xlarge

  • i2g, instance family equipped with local SSDs, which includes a variety of instance types such as ecs.i2g.2xlarge

  • gn5, GPU-accelerated compute optimized instance family, which includes a variety of instance types such as ecs.gn5-c4g1.xlarge.

    Note

    gn5 is a GPU-accelerated instance family. If you select this instance family, you must specify GPU-related parameters in addition to local disk-related parameters. For more information, see Create a GPU-accelerated elastic container instance.

For more information, see:

Kubernetes mode

You can add annotations to metadata in the configuration file of the pod to specify an ECS instance type equipped with local disks. Local disks have the same lifecycle as the elastic container instances to which the disks are attached. Local disks cannot be attached as persistent volumes (PVs) but can be attached as flex volumes.

Sample code:

apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
  name: nginx-i2
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        k8s.aliyun.com/eci-use-specs: ecs.i2.4xlarge  #Specify an ECS instance type equipped with local disks.
    spec:
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
          - name: disk1
            mountPath: /data1
          - name: disk2
            mountPath: /data2
      volumes:       #Attach local disks to the elastic container instance. Make sure that the number of specified local disks does not exceed the number of local disks supported by the specified ECS instance type. 
        - name: disk1
          flexVolume:
            driver: alicloud/local-disk
            fsType: ext4
        - name: disk2
          flexVolume:
            driver:  alicloud/local-disk
            fsType: ext4

API mode

When you call the CreateContainerGroup operation to create an elastic container instance, you can use the InstanceType parameter to specify ECS instance types and the volume-related parameters to attach local disks. The following table describes the parameters. For more information, see CreateContainerGroup.

Parameter

Type

Required

Example

Description

InstanceType

String

No

ecs.gn6v-c8g1.2xlarge

The ECS instance types. The following instance families equipped with local disks are supported: d1, d1ne, i2, i2g, and gn5. You can specify up to five ECS instance types at a time. Separate multiple instance types with commas (,). Example: ecs.d1.2xlarge,ecs.d1ne.2xlarge.

Volume.N.Name

String

No

disk1

The name of volume N.

Volume.N.Type

String

No

flexvolume

The type of volume N.

Volume.N.FlexVolume.Driver

String

No

alicloud/local-disk

The name of the FlexVolume driver for volume N. Set the value to alicloud/local-disk.

Volume.N.FlexVolume.FsType

String

No

ext4

The type of the file system for volume N. The default value is determined by the script of FlexVolume.

Notice

  • When you create an elastic container instance that has local disks attached, make sure that the number of volumes does not exceed the number of local disks supported by each of the specified ECS instance types.

  • If the specified ECS instance type is equipped with multiple local disks, the disks can be attached in any order because they all have the same specifications.

  • Local disks are physically located on a single physical server, which increases the risks of SPOFs. The durability of data stored on local disks is determined by the reliability of the associated physical server. For more information, see the "Limits" section of Local disks.