Create an ECI scaling group

Updated at:

A scaling group is a collection of instances with the same application scenario and instance type (ECS or ECI). When running container applications on ECI, you can use Auto Scaling to scale ECI instances based on the workload. This maintains application availability while reducing costs.

Procedure

Before you begin, choose a method to create a scaling group. Alibaba Cloud provides multiple methods. Follow the guide for your chosen method.

Method 1: From an existing ECI instance

To create an ECI scaling group based on an existing ECI instance's configuration, follow these steps.

  1. Go to the Create page.

    1. Sign in to the Auto Scaling console.

    2. In the top navigation bar, select the region where Auto Scaling is activated.

    3. In the left-side navigation pane, click Scaling Groups.

    4. On the Scaling Groups page, click Create to go to the Create page.

  2. Click the Create by Form tab and configure the parameters as prompted.

    The following table describes the required parameters. For information about all parameters, see Parameter descriptions.

    Required parameters

    Parameter

    Description

    Scaling Group Name

    Enter a name for the scaling group.

    Type

    Select the type of instances in the scaling group. Select ECI.

    Instance Configuration Source

    Select Select Existing Instance. Auto Scaling creates new instances based on the configuration of the selected instance.

    Minimum Number of Instances

    The minimum number of instances in the scaling group. If the number of instances falls below this limit, Auto Scaling automatically adds new instances.

    Maximum Number of Instances

    The maximum number of instances in the scaling group. If the number of instances exceeds this limit, Auto Scaling automatically removes instances.

    Default Cool-down Time

    The default cooldown time in seconds after a scaling activity is complete. You can use the default value of 300. For more information, see cooldown time.

    VPC

    All instances in your scaling group are created in this VPC. When you create a scaling group from an existing ECI instance, the VPC is automatically configured based on the selected ECI instance. You can change this setting.

    Warning

    You cannot change the VPC after you create the scaling group.

    vSwitch

    After selecting a VPC, select one or more vSwitches within that VPC. All instances in your scaling group are created in the selected vSwitches.

    Important

    We recommend that you select vSwitches in multiple zones. If you select a vSwitch in a single zone, scaling activities may fail due to insufficient inventory in that zone.

  3. Click Create to create the scaling group.

Note
  • When you create a scaling group from an existing ECI instance, Auto Scaling automatically creates a scaling configuration for the group. To manage this scaling configuration, see Manage scaling configurations.

  • Enable the scaling group so it can start working immediately. For more information, see Enable or disable a scaling group.

Method 2: From scratch

To create a scaling group first and specify the instance configuration source later, follow these steps.

  1. Go to the Create page.

    1. Sign in to the Auto Scaling console.

    2. In the top navigation bar, select the region where Auto Scaling is activated.

    3. In the left-side navigation pane, click Scaling Groups.

    4. On the Scaling Groups page, click Create to go to the Create page.

  2. Click the Create by Form tab and configure the parameters as prompted.

    The following table describes the required parameters. For information about all parameters, see Parameter descriptions.

    Required parameters

    Parameter

    Description

    Scaling Group Name

    Enter a name for the scaling group.

    Type

    Select the type of instances in the scaling group. Select ECI.

    Note

    This topic describes how to create an ECI scaling group. To create an ECS scaling group, see Create an ECS scaling group.

    Instance Configuration Source

    Select Create from Scratch. You can create the scaling group first and then configure the Instance Configuration Source. For more information, see Overview of instance configuration sources.

    Minimum Number of Instances

    The minimum number of instances in the scaling group. If the number of instances falls below this limit, Auto Scaling automatically adds new instances.

    Maximum Number of Instances

    The maximum number of instances in the scaling group. If the number of instances exceeds this limit, Auto Scaling automatically removes instances.

    Default Cool-down Time

    The default cooldown time in seconds after a scaling activity is complete. You can use the default value of 300. For more information, see cooldown time.

    VPC

    All instances in your scaling group are created in this VPC.

    Warning

    You cannot change the VPC after you create the scaling group.

    vSwitch

    After selecting a VPC, select one or more vSwitches within that VPC. All instances in your scaling group are created in the selected vSwitches.

    Important

    We recommend that you select vSwitches in multiple zones. If you select a vSwitch in a single zone, scaling activities may fail due to insufficient inventory in that zone.

  3. Click Create to create the scaling group.

Note

After creating the scaling group, you can follow the prompts to go to the page for creating a scaling configuration, or you can create one at a later time. For more information, see Create a scaling configuration for ECI instances.

Method 3: From a Kubernetes YAML file

To use a Kubernetes-style YAML file to manage ECI scaling groups, follow these steps.

Console

This example shows how to use a YAML file in the console to create an ECI scaling group that uses the Nginx:latest image.

  1. Go to the Create page.

    1. Sign in to the Auto Scaling console.

    2. In the top navigation bar, select the region where Auto Scaling is activated.

    3. In the left-side navigation pane, click Scaling Groups.

    4. On the Scaling Groups page, click Create to go to the Create page.

  2. Click the Create by YAML File tab and compose the YAML file.

    Use the following sample YAML file.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-demo
      annotations:
        # The name of the scaling group.
        k8s.aliyun.com/ess-scaling-group-name: use-yaml-create-scaling-group
        # The minimum number of instances in the scaling group.
        k8s.aliyun.com/ess-scaling-group-min-size: '0'
        # The maximum number of instances in the scaling group.
        k8s.aliyun.com/ess-scaling-group-max-size: '5'
    spec:
      selector:
        matchLabels:
          app: nginx-demo
      # The desired number of instances (replicas) in the scaling group.
      replicas: 1
      template:
        metadata:
          labels:
              app: nginx-demo
          annotations:
            # Specifies whether to automatically create and associate an EIP.
            k8s.aliyun.com/eci-with-eip: 'true'
            # The vSwitch ID. You can specify up to eight vSwitches in the same VPC, separated by commas.
            k8s.aliyun.com/eci-vswitch: vsw-bp******1,vsw-bp******2,vsw-bp******3,vsw-bp******4
            # The security group ID. You can specify up to five security groups in the same VPC, separated by commas.
            k8s.aliyun.com/eci-security-group: sg-bp******1,sg-bp******2
        spec:
          containers:
            - name: nginx
              # The image.
              image: nginx:latest
              ports:
                - containerPort: 80
                  name: http
                - containerPort: 443
                  name: https
              resources:
                requests:
                  memory: 0.05Gi
                  cpu: 50m
                limits:
                  memory: 1Gi
                  cpu: '1'
    

    The following table describes the parameters in the sample YAML file. For information about all supported parameters, see YAML parameter descriptions.

    Parameters in the sample YAML file

    Parameter

    Description

    Example

    k8s.aliyun.com/ess-scaling-group-name

    The name of the scaling group.

    use-yaml-create-scaling-group

    k8s.aliyun.com/ess-scaling-group-min-size

    The minimum number of instances in the scaling group.

    0

    k8s.aliyun.com/ess-scaling-group-max-size

    The maximum number of instances in the scaling group.

    5

    k8s.aliyun.com/eci-with-eip

    Specifies whether to automatically assign an EIP. Set to true to assign an EIP automatically.

    true

    k8s.aliyun.com/eci-vswitch

    The ID of the vSwitch. You can specify up to eight vSwitches in the same VPC. Separate multiple IDs with commas.

    Important

    If you do not specify a VPC and a vSwitch, Auto Scaling uses or creates a default VPC and vSwitch. For more information, see Default VPCs and vSwitches.

    vsw-bp******1,vsw-bp******2,vsw-bp******3

    k8s.aliyun.com/eci-security-group

    The ID of the security group. You can specify up to five security groups in the same VPC.

    Important

    The security group must be in the same VPC as the vSwitch.

    sg-bp******1,sg-bp******2

  3. Click Create to create the scaling group.

CLI

You can use Alibaba Cloud CLI to manage scaling groups from the command line. This example shows how to create an ECI scaling group that uses the Nginx:latest image by using a YAML file.

Important

Before you begin, install Alibaba Cloud CLI and configure your credentials and environment variables. For more information, see What is Alibaba Cloud CLI?

  1. Create a file named use-yaml-create-scaling-group.yaml with the following content.

    Use the following sample YAML file.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-demo
      annotations:
        # The name of the scaling group.
        k8s.aliyun.com/ess-scaling-group-name: use-yaml-create-scaling-group
        # The minimum number of instances in the scaling group.
        k8s.aliyun.com/ess-scaling-group-min-size: '0'
        # The maximum number of instances in the scaling group.
        k8s.aliyun.com/ess-scaling-group-max-size: '5'
    spec:
      selector:
        matchLabels:
          app: nginx-demo
      # The desired number of instances (replicas) in the scaling group.
      replicas: 1
      template:
        metadata:
          labels:
              app: nginx-demo
          annotations:
            # Specifies whether to automatically create and associate an EIP.
            k8s.aliyun.com/eci-with-eip: 'true'
            # The vSwitch ID. You can specify up to eight vSwitches in the same VPC, separated by commas.
            k8s.aliyun.com/eci-vswitch: vsw-bp******1,vsw-bp******2,vsw-bp******3,vsw-bp******4
            # The security group ID. You can specify up to five security groups in the same VPC, separated by commas.
            k8s.aliyun.com/eci-security-group: sg-bp******1,sg-bp******2
        spec:
          containers:
            - name: nginx
              # The image.
              image: nginx:latest
              ports:
                - containerPort: 80
                  name: http
                - containerPort: 443
                  name: https
              resources:
                requests:
                  memory: 0.05Gi
                  cpu: 50m
                limits:
                  memory: 1Gi
                  cpu: '1'
    

    The following table describes the parameters in the sample YAML file. For information about all supported parameters, see YAML parameter descriptions.

    Parameters in the sample YAML file

    Parameter

    Description

    Example

    k8s.aliyun.com/ess-scaling-group-name

    The name of the scaling group.

    use-yaml-create-scaling-group

    k8s.aliyun.com/ess-scaling-group-min-size

    The minimum number of instances in the scaling group.

    0

    k8s.aliyun.com/ess-scaling-group-max-size

    The maximum number of instances in the scaling group.

    5

    k8s.aliyun.com/eci-with-eip

    Specifies whether to automatically assign an EIP. Set to true to assign an EIP automatically.

    true

    k8s.aliyun.com/eci-vswitch

    The ID of the vSwitch. You can specify up to eight vSwitches in the same VPC. Separate multiple IDs with commas.

    Important

    If you do not specify a VPC and a vSwitch, Auto Scaling uses or creates a default VPC and vSwitch. For more information, see Default VPCs and vSwitches.

    vsw-bp******1,vsw-bp******2,vsw-bp******3

    k8s.aliyun.com/eci-security-group

    The ID of the security group. You can specify up to five security groups in the same VPC.

    Important

    The security group must be in the same VPC as the vSwitch.

    sg-bp******1,sg-bp******2

  2. In the same directory as the use-yaml-create-scaling-group.yaml file, run the following command to create the scaling group.

    Important
    aliyun ess ApplyScalingGroup --RegionId cn-hangzhou --Content "$(cat use-yaml-create-scaling-group.yaml)" --version 2022-02-22 --method POST --force

Parameters

Basic configuration

Parameter

Description

Scaling Group Name

The name of the scaling group. The name must be 2 to 64 characters in length, begin with a letter, digit, or Chinese character, and can contain periods (.), underscores (_), and hyphens (-).

Type

Specifies the type of instances that make up the scaling group. Auto Scaling manages and scales instances of this type.

  • ECS: All instances in the scaling group are ECS instances.

  • ECI: All instances in the scaling group are ECI instances.

Instance Configuration Source

Auto Scaling uses this configuration to create instances. A scaling group supports the following sources of instance configuration:

  • Launch Templates: Contains configuration information, such as the key pair, RAM role, instance type, and network settings. Passwords are not included. This parameter is available only when Type is set to ECS.

    A single instance type may cause scale-out failures due to insufficient inventory. You can select multiple instance types in the Extend Configurations of Launch Template section to improve the scale-out success rate. For more information, see Use a launch template to configure multiple instance types and improve scale-out success rate.

  • Select Existing Instance: You can select an existing instance. Auto Scaling automatically extracts the basic configuration information from the instance to create a default scaling configuration.

    Important
    • A scaling configuration extracted from an ECS instance includes basic configurations such as the instance type, network type, security group, and base image. The logon password and tags are not included. The base image is the image used by the existing instance and does not include data on the instance, such as applications. If you want the scaling configuration to include all system configurations and data of the instance, create a custom image for the instance.

  • Create from Scratch: Create instances without using a predefined template. After the scaling group is created, you can create a scaling configuration or specify a launch template. The procedure to create a scaling configuration varies based on the scaling group type. For more information, see Create a scaling configuration (for ECS instances) and Create a scaling configuration (for ECI instances).

Note

When you create a scaling group from an instance in the ECS console, Auto Scaling automatically populates information related to the source of instance configuration and network type. We recommend that you keep the default settings.

Suspend Process

Allows you to suspend specific processes before you perform certain operations. For example, you can suspend the health check process before you stop an instance to prevent the instance from being marked as unhealthy and automatically removed from the scaling group. The following processes can be suspended:

  • Scale-out: The scaling group rejects all scale-out activities.

  • Scale-in: The scaling group rejects all scale-in activities.

  • Health Check: Suspends the process of marking instances as unhealthy and removing them.

  • Scheduled Tasks: Prevents associated scaling rules from being triggered when a scheduled task is due.

  • Event-triggered Tasks: Prevents associated scaling rules from being triggered when an alarm-triggered task enters the Alarm state.

For more information, see Suspend and resume processes for a scaling group.

Deletion Protection

After you enable scaling group protection, you cannot delete the scaling group in the Auto Scaling console or by calling an API. This feature prevents accidental deletion of the scaling group.

Instance Health Check

If you enable health checks, the scaling group periodically checks the running status of instances. If an instance is not in the Running state, Auto Scaling considers it unhealthy and removes it. For more information, see Lifecycle of instances in a scaling group. The following options are supported:

  • Disable: Disables this feature.

  • Instance Status Check: Performs health checks on the status of instances in the scaling group.

  • Load Balancer Health Check: This option uses the health check results from an Application Load Balancer (ALB) or a Network Load Balancer (NLB) to determine instance health. (Classic Load Balancer (CLB) is not supported.)

Maximum instance lifetime (seconds)

The maximum amount of time that an instance can remain in the scaling group. When an instance exceeds its maximum lifetime, Auto Scaling automatically creates a new instance to replace it.

Note

This parameter is available only when Type is set to ECS.

Instance quantity

Parameter

Description

Minimum Number of Instances

If the number of instances falls below the minimum size, Auto Scaling adds instances to meet this minimum.

Maximum Number of Instances

If the number of instances exceeds the maximum size, Auto Scaling removes instances to meet this maximum. For more information about instance removal policies, see Configure a removal policy for a scaling group.

Expected Number of Instances

The target number of instances that Auto Scaling maintains in the scaling group. For more information, see Desired capacity.

Scaling and removal policies

Important

For ECI scaling groups, you cannot change the Scaling Policy, Instance Removing Policy, or Instance Reclaim Mode. ECI scaling groups use the following default settings:

  • Scaling Policy: Priority Policy.

  • Instance Removing Policy: First, filter for instances created from the oldest scaling configuration, and then remove the Earliest Instances.

  • Instance Reclaim Mode: Release.

Parameter

Description

Scaling Policy

By default, a scaling group scales instances based on the order of the vSwitches you configure. This behavior is called the priority policy. You can change the Scaling Policy to implement other strategies.

Important

You can modify this setting only when the Type is ECS and the Network Type is VPC. When the Type is ECI, the default Scaling Policy is the Priority.

  • Priority (default policy)

    Scales out or in based on the priority that you define for the vSwitches. During a scale-out event, the system first attempts to create an instance in the zone of the highest-priority vSwitch. If creation fails, the system automatically tries the zone of the next-highest priority vSwitch.

  • Distribution Balancing

    Use this policy to keep instances in your scaling group evenly distributed across multiple zones to help achieve multi-zone disaster recovery. If the number of ECS instances becomes unbalanced across zones for reasons such as insufficient inventory, you can perform a rebalance. For more information, see Rebalance ECS instances.

  • Cost Optimization

    Use the Cost Optimization when cost is a high priority. During a scale-out, this policy attempts to launch instances in ascending order of their vCPU unit price. If the scaling configuration includes multiple instance types that can be created as spot instances, the policy prioritizes these spot instances. If launching spot instances fails for reasons such as insufficient inventory, the policy automatically attempts to create pay-as-you-go instances. During a scale-in, the instance with the highest vCPU unit price is removed first.

  • Custom Combination Policy

    This policy gives you fine-grained control over your capacity distribution. You can use it to adjust the ratio of pay-as-you-go to spot instances, balance capacity across zones, and define the instance type selection strategy.

For configuration instructions, see Configure a scaling policy.

Instance Removing Policy

When instances need to be removed from a scaling group, Auto Scaling first filters instances based on the selected policy. If multiple instances meet the criteria, one is randomly selected for removal. This parameter is supported only when Type is set to ECS. The following options are available:

  • Instances Created From Earliest Scaling Configuration: Prioritizes removing instances created from the oldest scaling configuration. Manually added instances are not associated with a scaling configuration or launch template and are not selected first. If all instances associated with scaling configurations or launch templates have been removed but more instances need to be removed, manually added instances are then randomly removed.

    Important
    • In this context, scaling configuration refers to both scaling configurations and launch templates that are specified as the source of instance configuration.

    • The time associated with this option is related to when the template was configured for the scaling group, not the version of the launch template. For example:

      If a scaling group first uses version 2 of a launch template and is later rolled back to use version 1, version 2 of the launch template is considered the oldest scaling configuration.

  • Earliest Instances: Prioritizes the oldest instance for removal.

  • Most Recent Instances: Prioritizes the newest instance for removal.

  • Custom Policy: Defines a custom removal policy that filters instances based on the service name, version, and function name from Function Compute.

When Instance Removing Policy is set to Instances Created From Earliest Scaling Configuration or Custom Policy, multiple instances may meet the criteria. You can configure a secondary policy to further filter the instances to be removed. The following secondary policies are available:

  • - No Policy -: No secondary filtering is performed.

  • Earliest Instances: From the instances filtered by the primary policy, selects the one that was created earliest.

  • Most Recent Instances: From the instances filtered by the primary policy, selects the one that was created most recently.

Note

The removal of instances is also affected by the Scaling Policy of the scaling group. For more information, see Configure a removal policy for a scaling group.

Instance Reclaim Mode

Defines how Auto Scaling handles an instance after it is removed from the scaling group. The following reclamation modes are available:

Note

This parameter is configurable only when Type is set to ECS and Network Type is set to VPC. For ECI scaling groups, the default reclamation mode is Release.

  • Release: The removed instance is released, and no resources are retained. During a scale-out event, Auto Scaling creates new instances and adds them to the scaling group.

  • Economical Mode: The removed ECS instance is stopped and enters Economical Mode, where some resources are retained and billed. During a scale-out event, Auto Scaling prioritizes adding stopped ECS instances back to the scaling group. New ECS instances are created only if the scale-out quantity is not met. This mode improves scaling efficiency. For more information, see Use Economical Mode to improve scaling efficiency.

    Important
    • Do not store application data or logs on instances to avoid the risk of data loss when instances are reclaimed.

    • Stopped instances may be released in the following cases:

      • If you manually decrease the maximum size of the scaling group to a value smaller than the total number of instances in all states (including stopped), Auto Scaling prioritizes releasing the stopped ECS instances.

      • A stopped instance may fail to be added back to the scaling group due to insufficient inventory or an overdue payment. If this occurs, the instance is released.

    • The effectiveness of Economical Mode is influenced by the Economical Mode for pay-as-you-go instances. For more information, see the "Conditions", "Applicable resources", and "Effects" sections of Economical Mode.

  • Force Release: If you select this reclamation mode, the system forcibly releases instances that are in the Running (Running) state during a scale-in event.

    Warning

    Forcibly releasing an instance is equivalent to a power-off operation. It erases temporary data from the instance's memory and storage. Data cannot be recovered. Select this option with caution.

  • Force Economical Mode: If you select this reclamation mode, the system forcibly stops instances that are in the Running (Running) state during a scale-in event.

    Warning

    Forcibly stopping an instance is equivalent to a power-off operation. It erases temporary data from the instance's memory and storage. Data cannot be recovered. Select this option with caution.

Network configuration

Important

When Instance Configuration Source is set to Launch Templates or Select Existing Instance, parameters such as Network Type, VPC, and vSwitch are automatically populated based on the launch template or selected instance. You can also reconfigure the network settings for the scaling group as needed.

Parameter

Description

Network Type

Select a network type for the instances in your scaling group. VPC and Classic Network are supported.

Warning

The Network Type cannot be changed after the scaling group is created.

Important

We recommend that you select VPC. Scaling groups in a VPC support more flexible configurations, such as more flexible scaling policies, instance reclamation modes, and association with Application Load Balancers (ALBs) and Network Load Balancers (NLBs). For more information about VPC, see What is a Virtual Private Cloud (VPC)?.

VPC

This parameter is available when Network Type is set to VPC. After you select a VPC, all instances in your scaling group are created within that VPC.

Warning

The VPC cannot be changed after the scaling group is created.

vSwitch

After you select a VPC, you can select VSwitches that belong to the VPC. All instances in your scaling group are created in the selected VSwitches.

Important

We recommend that you select VSwitches in multiple availability zones. This helps prevent instance creation failures due to insufficient inventory in a single availability zone. If you use an ECS scaling group, you can also change the Scaling Policy to control the distribution of instances across availability zones.

Service integrations

Parameter

Description

Associate with ApsaraDB RDS, Redis, or MongoDB

If your instances need to access RDS, Redis, or MongoDB databases, you can associate the databases here. This automatically adds the internal IP addresses of new instances to the IP whitelist of the associated databases.

Note

Associated CLB Instances (Formerly Known as SLB Instances)

After a scaling group is associated with a CLB instance, instances added to the scaling group are automatically added as backend servers to the CLB instance to process requests forwarded by the CLB instance.

You can specify the server group to which instances are added. The following two types of server groups are supported:

  • Default server group: Used to receive front-end requests. If no vServer group or primary/secondary server group is configured for the listener, requests are forwarded to the instances in the default server group by default.

  • vServer group: You can use vServer groups if you need to forward different requests to different backend servers, or if you need to forward requests based on domain names and URLs.

If you specify both a default server group and multiple vServer groups, instances are added to all of these server groups simultaneously.

Note

A scaling group can be associated with a limited number of CLB instances and vServer groups. To view your quota or request a quota increase, go to Quota Center.

Associate with ALB and NLB server groups

Important

This parameter is available only when Network Type is set to VPC.

After a scaling group is associated with ALB or NLB server groups, instances added to the scaling group are automatically added as backend servers to the server groups to process requests distributed by the ALB or NLB instances. You must also specify the port and weight for the backend servers. The default weight is 50. The higher the weight, the more requests an instance receives. If the weight is 0, the instance does not receive any requests.

If you associate a scaling group with multiple ALB or NLB server groups, instances added to the scaling group are added to all of these server groups simultaneously.

Note

A scaling group can be associated with a limited number of ALB and NLB server groups. To view your quota or request a quota increase, go to Quota Center.

Other configurations

Parameter

Description

Tag

Add tags to facilitate searching for and organizing scaling groups. For more information, see Tags.

Note

Tags configured here apply to the scaling group. To add tags to instances within the scaling group, set the tags in the scaling configuration or launch template.

Tags Propagated to Instances During Scale-out

Propagates selected scaling group tags to new instances during scale-out events.

Add Existing Instance

This parameter is available when Type is set to ECS and Instance Configuration Source is set to Launch Templates or Select Existing Instance.

If you set a desired capacity and add existing instances at the same time, the desired capacity automatically increases. For example, if you set the desired capacity to 1 and add two existing instances when you create a scaling group, the two existing instances are added to the scaling group after it is created, and the desired capacity then becomes 3.

To let the scaling group manage the lifecycle of existing instances, select the Enable the scaling group to manage the instance lifecycle checkbox.

  • If the scaling group manages the instance lifecycle, an added existing instance is automatically released if it is removed from the scaling group for reasons such as being unhealthy, or if it is manually removed.

  • If the scaling group does not manage the instance lifecycle, an added existing instance is not automatically released when it is removed from the scaling group.

Note

You can add subscription instances to a scaling group, but you cannot let the scaling group manage the lifecycle of subscription instances.

Create Regular Rule

Auto Scaling can send notifications by SMS, internal messages, and email when a scaling activity succeeds, fails, or is rejected. For more information, see Configure notifications.

Resource Group

Select a resource group to organize your scaling group resources. This enables isolated resource views and access control. For more information, see Use resource groups for fine-grained management of scaling groups.

Synchronize Alert Rule to CloudMonitor

This feature can be enabled or disabled only when the scaling group is created. If you enable this feature, the system creates and associates a CloudMonitor application group with the scaling group, and the alarm rules for the scaling group are synchronized to and displayed in the CloudMonitor console.

YAML parameters

Kubernetes YAML fields

To deploy a scaling group of the Elastic Container Instance type using a Kubernetes YAML file, you can configure only the following fields from a Kubernetes Deployment resource.

Note

A YAML file typically consists of the kind, metadata, and spec sections. For details on the YAML file structure, see the sample Deployment on the official Kubernetes website.

Kubernetes YAML fields

  • kind: Specifies the resource type. Only the Deployment type is supported.

  • metadata.name: The name of the resource. This field is not used by the scaling group. Instead, the k8s.aliyun.com/ess-scaling-group-name annotation specifies the effective name.

  • spec.replicas: The number of Pod replicas. This value corresponds to the expected number of instances in the scaling group.

  • spec.template.spec: Defines the Pod configuration. The following features are supported:

    Feature

    YAML field

    Description

    DNS

    dnsPolicy

    The DNS policy.

    dnsConfig.nameservers

    A list of DNS server IP addresses.

    dnsConfig.searches

    A list of DNS search domains.

    dnsConfig.options.name

    The option name.

    dnsConfig.options.value

    The option value.

    Container

    containers.name

    The container name.

    containers.image

    The container image.

    containers.command

    The container's startup command.

    containers.args

    The arguments for the container startup command.

    containers.imagePullPolicy

    The image pull policy.

    containers.stdin

    Whether to allocate a buffer for stdin.

    containers.stdinOnce

    Whether to allocate a one-time buffer for stdin.

    containers.tty

    Whether to allocate a TTY.

    containers.ports

    containerPort

    The port number.

    protocol

    The protocol. Valid values: TCP and UDP.

    containers.env

    name

    The name of the environment variable.

    value

    The value of the environment variable.

    containers.resources

    requests.cpu

    The requested CPU resources.

    requests.memory

    The requested memory resources.

    limits.cpu

    The container's CPU limit.

    limits.memory

    The container's memory limit.

    limits.nvidia.com/gpu

    To specify a GPU model, add an annotation to the Pod metadata.

    Then, add the nvidia.com/gpu field to the container's resources to declare the required GPU resources.

    containers.securityContext

    runAsUser

    The user ID used to run the container.

    readOnlyRootFilesystem

    Whether the container's root file system is read-only.

    capabilities.add

    Grants specific permissions to processes in the container.

    containers.volumeMounts

    name

    This value must match the name of a volume.

    mountPath

    The path within the container where the volume is mounted.

    mountPropagation

    Determines how mounts are propagated from the host to the container and vice versa.

    readOnly

    Valid values:

    • true: The volume is mounted in read-only mode.

    • false: The volume is mounted in read-write mode.

    Default value: false.

    subPath

    The path within the volume.

    containers.livenessProbe

    • initialDelaySeconds

    • periodSeconds

    • successThreshold

    • timeoutSeconds

    • failureThreshold

    • exec.command

    • tcpSocket.port

    • httpGet.scheme

    • httpGet.port

    • httpGet.path

    Configure liveness, readiness, and startup probes

    containers.readinessProbe

    • initialDelaySeconds

    • periodSeconds

    • successThreshold

    • timeoutSeconds

    • failureThreshold

    • exec.command

    • tcpSocket.port

    • httpGet.scheme

    • httpGet.port

    • httpGet.path

    Init container

    initContainers.name

    The name of the init container.

    initContainers.image

    The image of the init container.

    initContainers.command

    The startup command for the init container.

    initContainers.args

    The arguments for the init container startup command.

    initContainers.imagePullPolicy

    The image pull policy for the init container.

    initContainers.env

    name

    The name of the environment variable for the init container.

    value

    The value of the environment variable for the init container.

    initContainers.resources

    requests.cpu

    The requested CPU resources for the init container.

    requests.memory

    The requested memory resources for the init container.

    limits.cpu

    The CPU limit for the init container.

    limits.memory

    The memory limit for the init container.

    limits.nvidia.com/gpu

    The GPU resources required by the init container.

    initContainers.securityContext

    capabilities.add

    Grants specific permissions to processes in the init container.

    initContainers.volumeMounts

    name

    The name of the volume for the init container. This value must match the name of a defined volume.

    mountPath

    The path within the init container where the volume is mounted.

    mountPropagation

    Determines how mounts are propagated from the host to the init container and vice versa.

    readOnly

    Valid values:

    • true: The volume is mounted in read-only mode.

    • false: The volume is mounted in read-write mode.

    Default value: false.

    subPath

    The path within the volume.

    Volume

    volumes.nfs

    name

    A custom name for the volume.

    server

    The address of the NFS server (NAS mount target).

    path

    The path of the NFS volume.

    readOnly

    Whether the volume is read-only.

    volumes.emptyDir

    sizeLimit

    The size limit for the emptyDir volume. The value must include a unit, for example, Gi or Mi.

    medium

    The storage medium for the emptyDir volume. Valid values:

    • If left empty or unspecified, the node's file system is used.

    • memory: uses memory as the storage medium.

    The default is empty.

    volumes.flexVolume

    driver

    The name of the driver for the FlexVolume.

    options

    A list of options for the FlexVolume object, passed as key-value pairs in JSON format.

    For example, to mount a cloud disk using a FlexVolume, specify options such as: {"volumeId":"d-2zehdahrwoa7srg****","performanceLevel": "PL2"}.

    Graceful shutdown

    terminationGracePeriodSeconds

    The grace period, in seconds, before the container is forcefully terminated. This allows the application time for a graceful shutdown.

Extended annotations

When you deploy a scaling group for Elastic Container Instance (ECI) using a Kubernetes YAML file, only the following extended annotations are supported.

Extended Annotations in Metadata

Parameter

Description

Example

k8s.aliyun.com/ess-scaling-group-name

The name of the scaling group.

ess-group-test

k8s.aliyun.com/ess-scaling-group-min-size

The minimum number of instances in the scaling group. Default value: 0.

0

k8s.aliyun.com/ess-scaling-group-max-size

The maximum number of instances in the scaling group. Default value: max(replicas, 30).

20

Extended Annotations in spec.template.spec

For more information about annotations, see ECI Pod Annotation.

Parameter

Example value

Description

k8s.aliyun.com/eci-ntp-server

100.100.*.*

The Network Time Protocol (NTP) server.

k8s.aliyun.com/eci-use-specs

2-4Gi

Specifies one or more ECI instance specifications. For more information, see Create Pods by specifying multiple specifications.

k8s.aliyun.com/eci-vswitch

vsw-bp1xpiowfm5vo8o3c****

Specifies the ID of the VSwitch. You can specify multiple VSwitch IDs to enable deployment across multiple availability zones.

k8s.aliyun.com/eci-security-group

sg-bp1dktddjsg5nktv****

Specifies the ID of the security group. The following requirements apply:

  • You can specify up to five security groups.

  • The specified security groups must belong to the same Virtual Private Cloud (VPC).

  • The specified security groups must be of the same type.

k8s.aliyun.com/eci-sls-enable

"false"

Set to false to disable log collection. When using Log Service CRDs to collect logs, you can add this annotation to Pods that do not require log collection to prevent the system from automatically creating a Logtail and wasting resources.

k8s.aliyun.com/eci-spot-strategy

SpotAsPriceGo

The bidding policy for the preemptible instance. Valid values:

  • SpotWithPriceLimit: Sets a custom price limit for the preemptible instance. You must also set k8s.aliyun.com/eci-spot-price-limit.

  • SpotAsPriceGo: The system automatically bids at the real-time market price.

k8s.aliyun.com/eci-spot-price-limit

"0.5"

The maximum hourly price for a preemptible instance supports up to three decimal places. Only when

k8s.aliyun.com/eci-spot-strategy

Set to

SpotWithPriceLimit

Takes effect.

k8s.aliyun.com/eci-with-eip

"true"

Set to true to automatically create and bind an Elastic IP Address (EIP).

k8s.aliyun.com/eci-data-cache-bucket

default

Specifies the bucket of the DataCache. This annotation is required when you create a Pod using a DataCache.

k8s.aliyun.com/eci-data-cache-pl

PL1

Specifies the performance level (PL) of the cloud disk created from the DataCache. By default, an ESSD (Enterprise SSD) is created, and its performance level defaults to PL1.

k8s.aliyun.com/eci-data-cache-provisionedIops

"40000"

Specifies the provisioned read/write IOPS for the ESSD AutoPL disk. Value range: 0 to min{50000, 1000 * capacity - baseline performance}, where baseline performance = min{1800 + 50 * capacity, 50000}. For more information, see ESSD AutoPL disks.

Adding this annotation creates an ESSD AutoPL disk from the DataCache.

k8s.aliyun.com/eci-data-cache-burstingEnabled

"true"

Specifies whether to enable the performance burst feature for the ESSD AutoPL disk. For more information, see ESSD AutoPL disks.

Adding this annotation creates an ESSD AutoPL disk from the DataCache.

k8s.aliyun.com/eci-custom-tags

"env:test,name:alice"

Specifies the tags to bind to the instance, provided as a single string. You can bind up to three tags. Use a colon (:) to separate a key from its value and a comma (,) to separate tags.

For more information about annotations, see ECI Pod Annotation.