All Products
Search
Document Center

Auto Scaling:ApplyScalingGroup

Last Updated:Sep 17, 2026

Creates and manages Elastic Container Instance (ECI)-based scaling groups by using a configuration file. You can call the ApplyScalingGroup operation to implement this feature.

Operation description

Operation description

ApplyScalingGroup supports the quick creation of ECI-based scaling groups in the Kubernetes Deployment resource definition format. ECI instances also support Kubernetes YAML extended annotations. For more information, see the "Supported annotations" section of this topic.

Mapping between YAML configurations and scaling groups: A scaling group name is mapped by the namespace, kind, and name triplet defined in the YAML configuration. Within a region, the same YAML configuration can map to only one scaling group. Example: If you use a Deployment YAML configuration with name set to nginx under the default namespace, it maps to a scaling group named k8s_default_Deployment_nginx in the same region.

Logic for managing scaling groups based on YAML configurations:

  • If the scaling group mapped by the YAML configuration exists, the scaling group is updated based on the YAML configuration.

  • If the scaling group mapped by the YAML configuration does not exist, a scaling group is created based on the YAML configuration.

Precautions

  • If the YAML configuration does not specify VPC, vSwitch, or security group annotations, the system performs automatic creation of a default VPC, a default vSwitch within the VPC, and a default Auto Scaling security group (ess-default-sg). The security group policy opens TCP ports 22 and 3389 and the ICMP (IPv4) protocol by default. If you require other port protocols, adjust the security group policy accordingly.

  • When using a public image, you must enable public network access. Set k8s.aliyun.com/eci-with-eip pod annotation to enable the EIP feature.

  • After ApplyScalingGroup applies the YAML configuration, the scaling group and scaling configuration take effect immediately. If replicas is set to a value greater than 0, automatic creation of resources is triggered.

Supported annotations

For more information about annotations, see ECI Pod Annotation.

ParameterExampleDescription
k8s.aliyun.com/ess-scaling-group-min-size1The minimum number of instances in the scaling group. Default value: 0.
k8s.aliyun.com/ess-scaling-group-max-size20The maximum number of instances in the scaling group. Default value: max(replicas, 30).
k8s.aliyun.com/eci-ntp-server100.100..The NTP server.
k8s.aliyun.com/eci-use-specs2-4GiThe specification of 2 vCPUs and 4 GiB of memory. For more information, see Create a pod with multiple specifications.
k8s.aliyun.com/eci-vswitchvsw-bp1xpiowfm5vo8o3c****The vSwitch ID. You can specify multiple vSwitches to implement the multi-zone feature.
k8s.aliyun.com/eci-security-groupsg-bp1dktddjsg5nktv****The security group ID. Requirements: You can specify one or more security groups, up to a maximum of five. The specified security groups must belong to the same VPC. The specified security groups must be of the same type.
k8s.aliyun.com/eci-sls-enable"false"Set this parameter to false to disable the log collection feature. When you collect logs by using SLS CRDs, if certain pods do not require log collection, configure this annotation to disable the log collection feature and avoid resource waste caused by automatic creation of Logtail.
k8s.aliyun.com/eci-spot-strategySpotAsPriceGoThe bidding policy for spot instances. Configure as needed. SpotWithPriceLimit: Set a custom price limit for spot instances. You must also set k8s.aliyun.com/eci-spot-price-limit. SpotAsPriceGo: The system automatically bids based on the current marketplace price.
k8s.aliyun.com/eci-spot-price-limit"0.5"The maximum hourly price for spot instances. The value can be accurate to three decimal places. This parameter takes effect only when k8s.aliyun.com/eci-spot-strategy is set to SpotWithPriceLimit.
k8s.aliyun.com/eci-with-eip"true"Set this parameter to true to automatically create and attach an EIP.
k8s.aliyun.com/eci-data-cache-bucketdefaultThe DataCache bucket. This parameter is required when you use DataCache to create a pod.
k8s.aliyun.com/eci-data-cache-plPL1The performance level (PL) of the cloud disk created based on DataCache. ESSD is used by default, and the default PL is PL1.
k8s.aliyun.com/eci-data-cache-provisionedIops"40000"The provisioned read/write IOPS of the ESSD AutoPL cloud disk. Valid values: 0 to min{50000, 1000 × capacity - baseline performance}, where baseline performance = min{1800 + 50 × capacity, 50000}. For more information, see ESSD AutoPL cloud disk. If this annotation is added, the cloud disk created based on DataCache is an ESSD AutoPL cloud disk.
k8s.aliyun.com/eci-data-cache-burstingEnabled"true"Specifies whether to enable burst (performance burst) for the ESSD AutoPL cloud disk. For more information, see ESSD AutoPL cloud disk. If this annotation is added, the cloud disk created based on DataCache is an ESSD AutoPL cloud disk.
k8s.aliyun.com/eci-custom-tags"env:test,name:alice"The tag string to attach. You can attach up to three tags. Separate tag keys and tag values with colons (:), and 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

ClientToken

string

No

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-42665544****

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 scaling group that takes effect.

asg-bp1igpak5ft1flyp****

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 IdempotentParameterMismatch The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.