To facilitate resource deployment or automate provisioning, you can configure Kubernetes YAML files in the Auto Scaling console to create scaling groups of the Elastic Container Instance type. This streamlines the efficient deployment of your business applications. By adopting this method, you can dedicate your focus to business logic development, thereby boosting productivity, while relieving yourself from the burden of managing the underlying infrastructure nodes and clusters. This topic describes how to use a Kubernetes YAML file to create and manage a scaling group of the Elastic Container Instance type.
Prerequisites
A container image is prepared and available for deployment.
In this topic, the sample container image is pulled from the registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest
address. You can also specify another image based on your business requirements.
Limits
You can use Kubernetes Deployments to create only scaling groups of the Elastic Container Instance type.
When you create a scaling group, note that configurations tied to Kubernetes clusters are not applicable because clusters operate independently of the underlying infrastructure. Configurations you make in this context will not take effect, as support is exclusively geared towards fields pertaining to Kubernetes Deployments.
On top of Kubernetes resources, you can configure Metadata Annotation in your Kubernetes YAML file to extend scaling group resources.
For example, you can specify the VPC for containers, the maximum and minimum size limits for the scaling group, and whether to enable supplementation of preemptible instances based on your business requirements.
NoteFor information about the supported YAML fields and annotations, see List of the supported YAML fields and annotations.
Procedure
Step 1: Create a scaling group by using a Kubernetes Deployment
Log on to the Auto Scaling console.
In the top navigation bar, select the region where Auto Scaling is activated.
In the left-side navigation pane, click Scaling Groups.
In the upper-left corner of the Scaling Groups page, click Create.
Click the Create By YAML File tab to edit the YAML file.
In this example, the initial content of the YAML file that is utilized for creating a scaling group is derived from the official sample Deployment configuration. You can also edit the Kubernetes Deployment YAML file online based on your business requirements.
The following table describes the YAML fields that you must modify based on your business requirements.
No.
Field
Description
①
replicas
The number of replicas.
For example, if you change the sample value of the
replicas
field to 1, the expected number of container instances is 1 in the scaling group that you want to create.②
image
The container image.
For example, you can change the sample value (a public image) of the
image
field to a private image residing in a VPC, such as an image from theregistry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest
address.③
annotations
The extended annotations.
In the Edit Extended Fields section on the right, configure Scaling Group Name, Minimum Number of Instances, Maximum Number of Instances, VPC, vSwitch, and Security Group based on your business requirements.
NoteAfter you complete the configuration, the system automatically incorporates the extended annotations into the YAML file displayed on the left.
Click Create. In the Confirm Information message, confirm the information and click Confirm.
Step 2: Verify the expected number of container instances in the scaling group
View the scaling group details to check whether the expected number of container instances matches the value of the
replicas
field. In this example, the expected number of container instances should be 1.For more information, see View or modify scaling groups.
View the instance list to check whether an elastic container instance is created in the scaling group.
For more information, see Manually configure instances for a scaling group.
(Optional) Step 3: View and download the YAML file
Find the scaling group that you created and click Details in the Actions column.
In the upper part of the scaling group details page, click the Instance Configuration Sources tab.
On the Scaling Configurations tab, find the desired scaling configuration and click View YAML in the Actions column.
You can view the details of the effective YAML file.
Click Download.
By default, the file is saved to your on-premises computer in the
.yaml
format for later use.
References
You can also call an API operation to configure a YAML file and then create a scaling group from the YAML file. For more information, see ApplyScalingGroup.