All Products
Search
Document Center

Elastic Container Instance:Specify or exclude specific ECS instance families to create a pod

Last Updated:Apr 08, 2024

If you create an Elastic Container Instance pod by specifying the number of vCPUs and memory size, you may have specific requirements for instance types of Elastic Compute Service (ECS). For example, you want to only use the ecs.g6 instance family to create the pod. In this case, you can add the k8s.aliyun.com/eci-instance-family annotation to specify ECS instance families. This topic describes how to specify or exclude specific ECS instance families when you create an Elastic Container Instance pod.

Feature description

When you create a pod by specifying the number of vCPUs and memory size, the system uses multiple ECS instance types to support the creation. The system automatically selects ECS instance types that meet the required vCPU and memory specifications and have sufficient resources. In this case, you can add the k8s.aliyun.com/eci-instance-family annotation to specify or exclude specific ECS instance families.

  • If you specify specific ECS instance families, the system selects ECS instance types only from the specified ECS instance families. If the resources of the specified ECS instance families are insufficient, the system does not create a pod.

  • If you exclude specific ECS instance families, the system selects instance types from other ECS instance families that are supported by Elastic Container Instance to create a pod.

Note

You can use the k8s.aliyun.com/eci-instance-family annotation together with the k8s.aliyun.com/eci-instance-generation annotation to implement more fine-grained control on ECS instance types. k8s.aliyun.com/eci-instance-generation specifies or excludes specific generations of ECS instance families.

The following table describes the ECS instance families that you can specify or exclude:

Architecture

Generation of ECS instance families

ECS instance family

ARM

8

g8y, c8y, and r8y

x86

7

g7, c7, r7, hfc7, hfg7, hfr7, and g7ne

6

g6e, g6, c6e, c6, r6e, r6, hfc6, hfg6, and t6

5

u1, g5,g5ne, c5, r5, ic5, hfc5, hfg5, and t5

4

sn2ne, sn1ne, se1ne, and se1

For more information about ECS instance types, see the following topics:

Precautions

  • Pods that are created based on specified or excluded ECS instance families are billed based on the actually used ECS instance type. The pods are not billed based on the specified specifications of vCPUs and memory.

    Important

    After a pod is created, you can run the kubectl describe pod command to view the YAML details of the pod. The value of the k8s.aliyun.com/eci-instance-spec field indicates the ECS instance type that is used by the pod. The pod is billed based on the ECS instance type.

  • When you specify or exclude specific ECS instance families, the system cannot automatically select specific instance types. For example, the system cannot automatically select GPU-accelerated instance types, such as the instance types of the gn6i instance family, and instance types equipped with local disks, such as instance types of the i2g instance family. If you want to use specific ECS instance types, create pods by specifying ECS instance types. For more information, see Specify ECS instance types to create a pod.

  • The feature of specifying or excluding specific ECS instance families takes effect only when you create pods by specifying the number of vCPUs and memory size. If you first specify ECS instance types when you create pods, the feature does not take effect.

  • If you specify or exclude specific ECS instance families to create a preemptible elastic container instance, the system selects the most suitable ECS instance type based on the sorting order of the instance families and the market price of the instance types. The market price takes precedence over the sorting order. If you have strict requirements for ECS instance families, we recommend that you configure only one instance family.

Configuration description

Valid values of k8s.aliyun.com/eci-instance-family are ECS instance families. Take note of the following items:

  • You can configure multiple instance families. Valid values: ECS instance families that are supported by Elastic Container Instance.

    Important

    The 8th-generation ECS instance families support only the ARM architecture. When you specify 8th-generation ECS instance families to create a pod, you must set the nodeSelector field to schedule the pod to an ARM-based virtual node. Therefore, you cannot specify 8th-generation ECS instance families together with the ECS instance families that use the x86 architecture. You must separately specify or exclude the 8th-generation ECS instance families. For more information, see Example 5: Specify ARM-based ECS instance families.

  • If you add a minus sign (-) before an instance family, the instance family is excluded to create the pod.

    For example, k8s.aliyun.com/eci-instance-family: "-ecs.c6, -ecs.c5" specifies that the ecs.c6 and ecs.c5 instance families are excluded.

  • The system selects the specified instance families based on their sorting order.

    For example, the k8s.aliyun.com/eci-instance-family: "ecs.c6, ecs.c5" annotation specifies that the system preferentially uses the ecs.c6 instance family. If the resources of the ecs.c6 instance family that meet the required vCPU and memory specifications are insufficient, the ecs.c5 instance family is used. If the resources of the ecs.c5 instance family are also insufficient, no pod is created.

Before you use the k8s.aliyun.com/eci-instance-family annotation, you must specify the specifications of vCPUs and memory by using one of the following methods:

  • Specify the limits or requests parameter of containers. We recommend that you specify the limits parameter.

  • Add the k8s.aliyun.com/eci-use-specs annotation to the metadata of the pod.

Example 1: Specify specific ECS instance families

Configuration item

Effect

  • The limits parameter is configured to define vCPU and memory resources (2 vCPUs, 4 GiB of memory).

  • The k8s.aliyun.com/eci-instance-family: "ecs.c6, ecs.g6" annotation is configured. The annotation specifies that the system first uses the ecs.c6 instance family and then the ecs.g6 instance family.

The system first uses the ecs.c6.large instance type and then the ecs.g6.large instance type.

Note

The effect of this example configuration is equivalent to the effect of k8s.aliyun.com/eci-use-specs: "ecs.c6.large,ecs.g6.large".

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      name: test
      labels:
        app: test
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-instance-family: "ecs.c6,ecs.g6"    # Specifies the ecs.c6 and ecs.g6 instance families are used in sequence.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80
        resources:
          limits:
            cpu: "2"       # Specifies the maximum number of vCPUs.        
            memory: "4Gi"  # Specifies the maximum memory size.

Example 2: Exclude specific ECS instance families

Configuration item

Effect

  • The k8s.aliyun.com/eci-use-specs: "2-4Gi" annotation is configured to define vCPU and memory resources (2 vCPUs, 4 GiB of memory).

  • The k8s.aliyun.com/eci-instance-family: "-ecs.t6,-ecs.t5" annotation is configured to exclude the ecs.t6 and ecs.t5 instance families.

The system selects instance types from ECS instance families (except ecs.t6 and ecs.t5) that are supported by Elastic Container Instance and meet the specification requirements for vCPUs and memory.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx-test
      labels:
        app: nginx
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-use-specs: "2-4Gi"                    # Specifies vCPU and memory specifications.
        k8s.aliyun.com/eci-instance-family: "-ecs.t6,-ecs.t5"    # Excludes the ecs.t6 and ecs.t5 instance families.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

Example 3: Specify specific generations of ECS instance families and exclude specific ECS instance families

Configuration item

Effect

  • The k8s.aliyun.com/eci-use-specs: "2-4Gi" annotation is configured to define vCPU and memory resources (2 vCPUs, 4 GiB of memory).

  • The k8s.aliyun.com/eci-instance-generation: "6,5" annotation is configured. The annotation specifies that the system first uses sixth-generation ECS instance families and then fifth-generation ECS instance families.

  • The k8s.aliyun.com/eci-instance-family: "-ecs.t5" annotation is configured to exclude the ecs.t5 instance family.

  • The system preferentially selects instance types from sixth-generation ECS instance families that meet the required vCPU and memory specifications.

  • If the resources of sixth-generation ECS instance families are insufficient, the system selects instance types from fifth-generation ECS instance families (except ecs.t5) that are supported by Elastic Container Instance.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx-test
      labels:
        app: nginx
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-use-specs: "2-4Gi"                   # Specifies vCPU and memory specifications.
        k8s.aliyun.com/eci-instance-generation: "6,5"           # Specifies that the sixth-generation ECS instance families and fifth-generation ECS instance families are used in sequence.
        k8s.aliyun.com/eci-instance-family: "-ecs.t5"           # Excludes the ecs.t5 instance family.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

Example 4: Exclude specific generations of ECS instance families and specific ECS instance families

Configuration item

Effect

  • The k8s.aliyun.com/eci-use-specs: "2-4Gi" annotation is configured to define vCPU and memory resources (2 vCPUs, 4 GiB of memory).

  • The k8s.aliyun.com/eci-instance-generation: "-5,-4" annotation is configured to exclude fifth- and fourth-generation ECS instance families.

  • The k8s.aliyun.com/eci-instance-family: "-ecs.t6" annotation is configured to exclude the ecs.t6 instance family.

The system selects instance types from seventh- and sixth-generation ECS instance families (except ecs.t6) that meet the required vCPU and memory specifications.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx-test
      labels:
        app: nginx
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-use-specs: "2-4Gi"                    # Specifies vCPU and memory specifications.
        k8s.aliyun.com/eci-instance-generation: "-5,-4"          # Excludes fifth- and fourth-generation ECS instance families.
        k8s.aliyun.com/eci-instance-family: "-ecs.t6"            # Excludes the ecs.t6 instance family.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

Example 5: Specify ARM-based ECS instance families

Configuration item

Effect

  • The k8s.aliyun.com/eci-use-specs: "2-4Gi,4-8Gi" annotation is added to specify the vCPU and memory specifications (2 vCPUs and 4 GiB of memory size, and 4 vCPUs and 8 GiB of memory size are used in sequence).

  • The k8s.aliyun.com/eci-instance-family: "ecs.c8y" annotation is added to specify the ecs.c8y instance family.

  • The alibabacloud.com/eci: "true" and kubernetes.io/arch: arm64 fields are specified to schedule the pod to an ARM-based virtual node.

The ecs.c8y.large and ecs.c8y.xlarge instance types are used in sequence.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx-test
      labels:
        app: nginx
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-use-specs: "2-4Gi,4-8Gi"              # Specifies multiple vCPU and memory specifications.
        k8s.aliyun.com/eci-instance-family: "ecs.c8y"            # Specifies the ecs.c8y instance family.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80
      nodeSelector:
        kubernetes.io/arch: arm64  # Schedules the pod to an ARM-based virtual node.

Example 6: Invalid setting

The feature of specifying or excluding specific ECS instance families takes effect only when you create pods by specifying the number of vCPUs and memory size. If you create pods by specifying ECS instance types, the feature does not take effect.

In the following example, the annotation that specifies the ecs.c6 instance family is automatically ignored, and only the ecs.c5.large instance type is used to create the pod.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx-test
      labels:
        app: nginx
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-use-specs: "ecs.c5.large"   # Specifies a specific ECS instance type.
        k8s.aliyun.com/eci-instance-family: "ecs.c6"   # Specifies a specific ECS instance family. The setting does not take effect.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80