All Products
Search
Document Center

Auto Scaling:ApplyScalingGroup

最終更新日:Nov 11, 2024

Creates and manages scaling groups by using configuration files. You can call the ApplyScalingGroup operation to create and manage scaling groups by using configuration files with efficiency.

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.
  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 GiB of 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 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 (,).|

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ess:ApplyScalingGroupcreate
  • All Resources
    *
    none
none

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
RegionIdstringNo

The region ID.

cn-hangzhou
FormatstringNo

Optional. The format of the configuration file. Default value: YAML. Set the value to YAML.

YAML

Response parameters

ParameterTypeDescriptionExample
object

Schema of Response

RequestIdstring

The request ID.

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

The ID of the enabled scaling group.

asg-bp1igpak5ft1flyp****

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