All Products
Search
Document Center

Auto Scaling:ApplyScalingGroup

Last Updated:Jun 06, 2024

Creates and manages scaling groups with ease by using configuration files.

Operation description

You can call the ApplyScalingGroup operation to create scaling groups of the Elastic Container Instance type with ease. The resources of the scaling groups are defined in Kubernetes Deployment YAML files. You can also call this operation to extend annotations for elastic container instances in Kubernetes Deployment YAML files. For more information, see "Supported annotations" in this topic.

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

You can use a Kubernetes Deployment YAML file to manage a scaling group based on the following logic:

  • If an existing scaling group has a mapping relationship with your Kubernetes Deployment YAML file, you can update the scaling group by using the YAML file.
  • If no scaling group that has a mapping relationship with your Kubernetes Deployment YAML file exists, you can create a scaling group with ease by using the YAML file.

Precautions

  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.

AnnotationExampleDescription
k8s.aliyun.com/ess-scaling-group-min-size1The minimum size of the scaling group that you want to create. Default value: 0.
k8s.aliyun.com/ess-scaling-group-max-size20The 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-server100.100..The IP address of the Network Time Protocol (NTP) server.
k8s.aliyun.com/eci-use-specs2-4GiThe specifications of 2 vCPUs and 4 GB memory. For more information, see Create pods by specifying multiple specifications.
k8s.aliyun.com/eci-vswitchvsw-bp1xpiowfm5vo8o3c****The ID of the vSwitch. You can specify multiple vSwitches to specify multiple zones.
k8s.aliyun.com/eci-security-groupsg-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 the preemptible instance. Valid values:

  • SpotWithPriceLimit: The instance is created as a preemptible instance for which you specify the maximum hourly price If you set the value to SpotWithPriceLimit, you must configure the k8s.aliyun.com/eci-spot-price-limit annotation.
  • SpotAsPriceGo: The instance is a preemptible instance for which the market price at the time of purchase is used as the bid price.
| |k8s.aliyun.com/eci-spot-price-limit|"0.5"|The maximum hourly price of the preemptible instance. 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 EIP is automatically created and bound to each elastic container instance.| |k8s.aliyun.com/eci-data-cache-bucket|default|The bucket of the specified DataCache. If you want to use a DataCache to create a pod, 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 by using the specified DataCache.

By default, enhanced 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.

If you configure this annotation, the cloud disk that is created by using the specified DataCache 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.

If you configure this annotation, the cloud disk that is created by using the specified DataCache 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 (,).|

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
ContentstringYes

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

Response parameters

ParameterTypeDescriptionExample
object

Schema of Response

Examples

Sample success responses

JSONformat

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

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history