All Products
Search
Document Center

Auto Scaling:ApplyScalingGroup

Last Updated:Aug 28, 2026

Creates and manages scaling groups by using configuration files.

Operation description

This operation creates Elastic Container Instance scaling groups with resources defined in Kubernetes Deployment YAML files. It also supports extending annotations for elastic container instances. For more information, see "Supported annotations" in this topic.

Mapping between YAML files and scaling groups: The triplet of namespace, kind, and name in a YAML file maps to a scaling group name. A YAML file and a scaling group have a one-to-one mapping in a region. For example, if you use a Kubernetes Deployment YAML file named NGINX in the default namespace to create a scaling group, the mapped scaling group name is k8s_default_Deployment_nginx.

A Kubernetes Deployment YAML file manages a scaling group with the following logic:

  • If an existing scaling group maps to your Kubernetes Deployment YAML file, the YAML file updates the scaling group.

  • If no scaling group maps to your Kubernetes Deployment YAML file, the YAML file creates a new scaling group.

  1. If you do not specify a virtual private cloud (VPC), vSwitch, security group, or annotation in your Kubernetes Deployment YAML file, the system creates a default VPC that has default vSwitches and uses the default security group ess-default-sg of Auto Scaling. By default, the security group rule allows traffic on Transmission Control Protocol (TCP)-based port 22 and port 3389 and enables Internet Control Message Protocol (ICMP) for IPv4 addresses. If you want to enable other ports or protocols, you can create custom security group rules.

  2. If you want to use a public image, you must enable the Internet access feature and configure the k8s.aliyun.com/eci-with-eip pod annotation to enable the elastic IP address (EIP) feature.

  3. After you call the ApplyScalingGroup operation to apply a Kubernetes Deployment YAML file, the scaling group immediately enters the Enabled state and the scaling configuration immediately enters the Active state. If the number of replicas that you specified in the YAML file is grater than 0, elastic container instances are automatically created.

Supported annotations

For more information about annotations, see ECI Pod Annotation.

Annotation Example Description
k8s.aliyun.com/ess-scaling-group-min-size 1 The minimum size of the scaling group that you want to create. Default value: 0.
k8s.aliyun.com/ess-scaling-group-max-size 20 The maximum size of the scaling group that you want to create. Default value: maximum number of replicas or 30, whichever is greater.
k8s.aliyun.com/eci-ntp-server 100.100.. The IP address of the Network Time Protocol (NTP) server.
k8s.aliyun.com/eci-use-specs 2-4Gi The specifications of 2 vCPUs and 4 GiB of memory. For more information, see Create pods by specifying multiple specifications.
k8s.aliyun.com/eci-vswitch vsw-bp1xpiowfm5vo8o3c**** The ID of the vSwitch. You can specify multiple vSwitches to specify multiple zones.
k8s.aliyun.com/eci-security-group sg-bp1dktddjsg5nktv**** The ID of the security group. Before you configure this annotation, take note of the following requirements:
  • You can specify one or more security groups. You can specify up to five security groups for each scaling group.

  • If you specify multiple security groups, the security groups must belong to the same VPC.

  • If you specify multiple security groups, the security groups must be of the same type.

k8s.aliyun.com/eci-sls-enable "false" If you set the value to false, the log collection feature is disabled.

If you do not want to use Custom Resource Definition (CRD) for Simple Log Service to collect logs of specific pods, you can configure this annotation for the pods and set the value to false. This prevents resource wastes caused by Logtails created by the system.| |k8s.aliyun.com/eci-spot-strategy|SpotAsPriceGo|The bidding policy for preemptible instances. Valid values:

  • SpotWithPriceLimit: The instances are created as preemptible instances with a maximum hourly price. If you set the value to SpotWithPriceLimit, you must configure the k8s.aliyun.com/eci-spot-price-limit annotation.

  • SpotAsPriceGo: The instances are created as preemptible instances for which the market price at the time of purchase is automatically used as the bid price.

| |k8s.aliyun.com/eci-spot-price-limit|"0.5"|The maximum hourly price of preemptible instances. This value can be accurate to up to three decimal places.

This annotation takes effect only when you set the k8s.aliyun.com/eci-spot-strategy annotation to SpotWithPriceLimit.| |k8s.aliyun.com/eci-with-eip|"true"|If you set the value to true, an elastic IP address (EIP) is automatically created and bound to each elastic container instance.| |k8s.aliyun.com/eci-data-cache-bucket|default|The bucket of data caches. If you want to create a pod based on data caches, you must configure this annotation.| |k8s.aliyun.com/eci-data-cache-pl|PL1|The performance level (PL) of the cloud disk that you want to create based on data caches.

By default, enterprise SSDs (ESSDs) are created. Default value: PL1.| |k8s.aliyun.com/eci-data-cache-provisionedIops|"40000"|The provisioned read/write IOPS of the ESSD AutoPL disk. Valid values: 0 to min{50000, 1000 × Capacity - Baseline IOPS}. Baseline IOPS = min{1,800 + 50 × Capacity, 50,000}. For more information, see ESSD AutoPL disks.

If you configure this annotation, the cloud disk that is created based on data caches is of the ESSD AutoPL type.| |k8s.aliyun.com/eci-data-cache-burstingEnabled|"true"|Specifies whether the Burst feature is enabled for the ESSD AutoPL disk. For more information, see ESSD AutoPL disks.

If you configure this annotation, the cloud disk that is created based on data caches is of the ESSD AutoPL type.| |k8s.aliyun.com/eci-custom-tags|"env:test,name:alice"|The tags that you want to add to each elastic container instance. You can add up to three tags for each elastic container instance. Separate a tag key and a tag value with a colon (:). Separate multiple tags with commas (,).|

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:ApplyScalingGroup

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Content

string

Yes

The content of the configuration file.

apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: k8s.aliyun.com/eip-bandwidth: 10 k8s.aliyun.com/eci-with-eip: true spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80

RegionId

string

No

The region ID.

cn-hangzhou

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID.

CC107349-57B7-4405-B1BF-9BF5AF7F****

ScalingGroupId

string

The ID of the enabled scaling group.

asg-bp1igpak5ft1flyp****

Examples

Success response

JSON format

{
  "RequestId": "CC107349-57B7-4405-B1BF-9BF5AF7F****",
  "ScalingGroupId": "asg-bp1igpak5ft1flyp****"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.