You can create an Elastic Container Instance (ECI) by specifying the CPU and memory specifications of the ECI or containers in the ECI. After you specify the CPU and memory specifications, the system checks the Elastic Compute Service (ECS) instance types that can meet the specification requirements and selects one to create the ECI. This mode provides better scalability and resource provision capabilities compared with the mode in which you specify a specific ECS instance type. This mode applies to most scenarios. We recommend that you use this mode if you do not have any special requirements, for example, high clock speeds, local solid-state disks (SSDs), and GPUs.

(Default mode in Kubernetes) Specify the CPU and memory specifications of containers in an ECI

Notice Each ECI supports up to 20 containers. You can customize the resources for each container. The total CPU and memory resources of all containers in an ECI must be a supported CPU and memory combination. ECI automatically adjusts the CPU and memory specifications if the total CPU and memory resources do not match any combination. The billing is based on the adjusted specifications.

The following table lists the supported specifications of an ECI.

vCPU Memory (GiB) emptyDir volume size (GiB) Bandwidth (Gbit/s) Packet forwarding rate (Kpps) IPv6 support NIC queue ENI (including one primary ENI)
0.25 0.5 and 1 20 0.1 40 No 1 1
0.5 1 and 2 20 0.2 50 No 1 1
1 2, 4, and 8 20 0.5 50 No 1 1
2 2, 4, 8, and 16 20 1 300 No 2 1
4 4, 8, 16, and 32 20 1.5 500 No 2 1
8 8, 16, 32, and 64 20 2.0 800 No 4 1
12 12, 24, 48, and 96 20 2.5 900 No 4 1
16 16, 32, 64, and 128 20 3.0 1,000 No 4 1
24 48, 96, and 192 20 4.5 1,500 No 6 1
32 64, 128, and 256 20 6.0 2,000 No 8 1
52 96, 192, and 384 20 12.5 3,000 No 32 1
64 128, 256, and 512 20 20.0 4,000 No 16 1
Note If you want to request more than 4 vCPUs for a container, you must declare the CPU and memory specifications in an API operation by strictly following the preceding table. Otherwise, an error message is returned, indicating that the specified specifications are invalid. This prevents specification adjustment caused by misoperation and avoids resource waste. If you want to request more than 4 vCPUs for a container, we recommend that you create the ECI by specifying the CPU and memory specifications of the ECI, instead of each container.

Kubernetes mode

You can specify the CPU and memory specifications in the native Kubernetes mode. That is, specify the CPU and memory specifications in the requests parameter for the corresponding container.

apiVersion: apps/v1beta2 # For versions earlier than 1.8.0, use apps/v1beta1.
kind: Deployment
metadata:
  name: nginx-deployment-basic
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9 # Replace it with your image name, in the format of <image_name:tags>.
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: "500m"
            memory: "1024Mi"
      - name: busybox
        image: busybox:latest # Replace it with your image name, in the format of <image_name:tags>.
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: "500m"
            memory: "1024Mi"

API mode

When you call the CreateContainerGroup operation to create an ECI, you can specify multiple zones through the VSwitchId parameter and specify multiple instance types through the InstanceType parameter. For more information about other parameters, see CreateContainerGroup.

The following table describes the parameters that you need to set in the request.

Parameter Type Required Example Description
Container.N.Cpu Float No 2 The number of vCPUs to be allocated to the container. N indicates the sequence number of the container. The value starts from 1 and increases by 1.
Container.N.Memory Float No 4 The size of the memory to be allocated to the container. Unit: GiB. N indicates the sequence number of the container. The value starts from 1 and increases by 1.

Specify the CPU and memory specifications of an ECI

After you specify the CPU and memory specifications, the system checks the ECS instance types that can meet the specification requirements and selects one to create the ECI. This mode provides better scalability and resource provision capabilities compared with the mode in which you specify a specific ECS instance type. You can specify the CPU and memory specifications of an ECI through an annotation in the pod definition. This allows you to specify the specifications in a mode compatible with Kubernetes.

Benefits

  • You do not need to specify the request and limit parameters when you define containers in the ECI. In this way, no resource limit is specified for containers in the ECI. This allows the containers to share the requested resources to the maximum extent.
  • In the genetic computation and Istio scenarios, the service framework automatically deploys a sidecar container in pods. By explicitly specifying the specifications of an ECI, you can seamlessly connect the ECI to the service framework.

Kubernetes mode

You can specify the CPU and memory specifications by using the k8s.aliyun.com/eci-use-specs annotation when you define a pod. For more information, see Pod annotations supported by ECI.

apiVersion: apps/v1beta2 # For versions earlier than 1.8.0, use apps/v1beta1.
kind: Deployment
metadata:
  name: nginx-deployment-basic
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        k8s.aliyun.com/eci-use-specs : "2-4Gi"  
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9 # Replace it with your image name, in the format of <image_name:tags>.
        ports:
        - containerPort: 80
      - name: busybox
        image: busybox:latest # Replace it with your image name, in the format of <image_name:tags>.
        ports:
        - containerPort: 80
        resources:
          limits:
            cpu: "500m"
            memory: "1024Mi"

API mode

When you call the CreateContainerGroup operation to create an ECI, you can specify multiple zones through the VSwitchId parameter and specify multiple instance types through the InstanceType parameter. For more information about other parameters, see CreateContainerGroup.

The following table describes the parameters that you need to set in the request.

Parameter Type Required Example Description
Cpu Float No 2 The number of vCPUs to be allocated to the ECI.
Memory Float No 4 The size of the memory to be allocated to the ECI. Unit: GiB.