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.
-
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.
-
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.
-
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:
|
| 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.
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
Test
RAM authorization
|
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.