All Products
Search
Document Center

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

Last Updated:Apr 01, 2026

When Elastic Container Instance (ECI) creates a pod based on vCPU and memory size, it automatically selects a compatible ECS instance type. Use the k8s.aliyun.com/eci-instance-generation annotation to constrain which ECS instance family generations the system can choose from — either by targeting specific generations or by excluding older ones.

How it works

ECI selects an ECS instance type that satisfies the vCPU and memory requirements and has available capacity. Adding k8s.aliyun.com/eci-instance-generation narrows that selection to specific generations:

  • Specify generations: ECI selects instance types only from the generations you list. If capacity is unavailable in those generations, pod creation fails.

  • Exclude generations: ECI selects instance types from all other generations it supports.

The order of generations in the annotation value determines selection priority. ECI tries the first listed generation, then falls back to the next if capacity is insufficient.

Supported generations

The following table lists the ECS instance families available in each generation.

GenerationECS instance families
8g8i, c8i, r8i, hfg8i, hfc8i, hfr8i
7g7, c7, r7, hfg7, hfc7, hfr7, g7ne
6g6e, g6, c6e, c6, r6e, r6, hfc6, hfg6
5u1, g5, g5ne, c5, r5, ic5, hfc5, hfg5
4sn2ne, sn1ne, se1ne, se1

For pricing and regional availability, see Pricing of ECS instance types and ECS instance types available for each region. For a full description of each instance family, see Overview of instance families.

Prerequisites

Before you begin, make sure that you have:

  • An ECI pod configured to use vCPU and memory size, not explicit instance types

  • vCPU and memory defined using one of the following methods:

    • The limits or requests parameter on a container (recommended: limits)

    • The k8s.aliyun.com/eci-use-specs annotation in fuzzy-search format (for example, "2-4Gi")

Important

k8s.aliyun.com/eci-instance-generation only takes effect when you create pods by specifying vCPU and memory size. If k8s.aliyun.com/eci-use-specs contains a specific ECS instance type (for example, ecs.c5.large), the generation annotation is ignored. See Example 5: Invalid configuration.

Configure the annotation

Add k8s.aliyun.com/eci-instance-generation to the annotations field in the pod metadata. The value is a comma-separated list of generation numbers. Valid values are: 4, 5, 6, and 7.

SyntaxEffectExample
"6,5"Use 6th-gen first, then 5th-genk8s.aliyun.com/eci-instance-generation: "6,5"
"-5,-4"Exclude 5th-gen and 4th-gen; use all othersk8s.aliyun.com/eci-instance-generation: "-5,-4"

Related annotations:

Use the following annotations together with k8s.aliyun.com/eci-instance-generation to further control instance selection.

AnnotationPurpose
k8s.aliyun.com/eci-instance-generationSpecify or exclude generations of ECS instance families
k8s.aliyun.com/eci-use-specsDefine vCPU and memory (fuzzy format) or specify explicit instance types
k8s.aliyun.com/eci-instance-familyInclude or exclude specific instance families (for example, -ecs.hfg5)

Verify the instance type used

After the pod is created, run the following command to confirm which ECS instance type ECI selected:

kubectl describe pod <pod-name>

Check the value of k8s.aliyun.com/eci-instance-spec in the output. The pod is billed based on this instance type, not based on the vCPU and memory size you specified.

Limitations

  • Unsupported instance types: ECI cannot automatically select GPU-accelerated instance types (such as the gn6i family) or instance types with local disks (such as the i2g family) when using generation constraints. To use those instance types, create pods by specifying ECS instance types explicitly. For more information, see Specify ECS instance types to create a pod.

  • Spot instances: Generation constraints work with spot elastic container instances. ECI selects the instance type based on market price and the generation order you configured. For strict generation control with spot instances, specify only one generation.

  • Billing: Pods are billed based on the ECS instance type that ECI actually uses, not the vCPU and memory size you specified.

Examples

Example 1: Specify generations

The following Deployment uses limits to specify 2 vCPUs and 4 GiB of memory. The annotation instructs ECI to try 6th-generation instance families first, then 5th-generation if 6th-generation capacity is unavailable.

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-instance-generation: "6,5"    # Use 6th-gen first, then 5th-gen.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80
        resources:
          limits:
            cpu: "2"       # Maximum vCPUs.
            memory: "4Gi"  # Maximum memory.

Example 2: Exclude generations

The following Deployment uses k8s.aliyun.com/eci-use-specs to specify 2 vCPUs and 4 GiB of memory in fuzzy-search format. The generation annotation excludes 5th-generation and 4th-generation instance families, so ECI selects from 7th-generation and 6th-generation families.

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"           # vCPU and memory in fuzzy-search format.
        k8s.aliyun.com/eci-instance-generation: "-5,-4"  # Exclude 5th-gen and 4th-gen.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

Example 3: Specify generations and exclude specific instance families

The following Deployment specifies 6th-generation and 5th-generation instance families in priority order, and also excludes the ecs.hfg5 instance family. ECI tries 6th-generation families first. If capacity is unavailable, it falls back to 5th-generation families, excluding ecs.hfg5.

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"             # vCPU and memory in fuzzy-search format.
        k8s.aliyun.com/eci-instance-generation: "6,5"     # Use 6th-gen first, then 5th-gen.
        k8s.aliyun.com/eci-instance-family: "-ecs.hfg5"   # Exclude the ecs.hfg5 instance family.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

Example 4: Exclude generations and specific instance families

The following Deployment excludes 5th-generation and 4th-generation instance families, and also excludes the ecs.hfg6 instance family. ECI selects from 7th-generation and 6th-generation families, with ecs.hfg6 excluded from the 6th-generation pool.

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"             # vCPU and memory in fuzzy-search format.
        k8s.aliyun.com/eci-instance-generation: "-5,-4"   # Exclude 5th-gen and 4th-gen.
        k8s.aliyun.com/eci-instance-family: "-ecs.hfg6"   # Exclude the ecs.hfg6 instance family.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

Example 5: Invalid configuration

k8s.aliyun.com/eci-instance-generation has no effect when k8s.aliyun.com/eci-use-specs specifies a concrete ECS instance type. In the following example, ECI ignores the generation annotation and uses only ecs.c5.large. An IgnoreInstanceTypeFeatures warning event is generated.

Event nameTypeMessageEvent description
IgnoreInstanceTypeFeaturesWarning[eci.containergroup]The instance type features will be ignored as the provided specifications, [%s],correspond exclusively to ECS instance types.The k8s.aliyun.com/eci-use-specs annotation defines the ECS instance types. This way, other annotations to specify the generations of ECS instance families are ignored.
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"   # Specific instance type — generation annotation is ignored.
        k8s.aliyun.com/eci-instance-generation: "6"    # No effect when eci-use-specs specifies an instance type.
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

What's next