To expedite business deployment based on Kubernetes YAML files, you can configure YAML files in the Auto Scaling console. This facilitates the creation of scaling configurations of the Elastic Container Instance type, allowing you to specify templates for the scale-outs of elastic container instances. This mode removes the need to focus on the O&M management of underlying nodes and clusters, effectively enhancing development efficiency. This topic describes how to use a Kubernetes YAML file to efficiently create a scaling configuration of the Elastic Container Instance type.
Prerequisites
A scaling group of the Elastic Container Instance type is created. For more information, see Use Kubernetes YAML files to configure scaling groups of the Elastic Container Instance type.
A container image is prepared and available for deployment.
You can directly use a regular Alibaba Cloud image. In this example, the sample 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 configurations of the Elastic Container Instance type.
When you create a scaling configuration, 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 native resources, you can configure
metadata.annotations
in your Kubernetes YAML file to specify configuration options for elastic container instances. For example, you can flexibly define the virtual private cloud (VPC), vSwitch, and security group settings for elastic container instances.NoteFor information about the supported YAML fields and annotations, see List of supported YAML fields and annotations.
Procedure
Step 1: Create a scaling configuration by using a Kubernetes Deployment
Log on to the Auto Scaling console.
In the left-side navigation pane, click Scaling Groups.
In the top navigation bar, select a region.
Find the desired scaling group and use one of the following methods to open the scaling group details page.
Click the ID of the scaling group in the Scaling Group Name/ID column.
Click Details in the Actions column.
In the upper part of the details page, click the Instance Configuration Sources tab.
On the Scaling Configurations tab, click Create Scaling Configuration.
Click the Create By YAML File tab to edit the YAML file.
In this example, the image that is pulled from the
registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest
address is used for reference only. You can edit the Kubernetes Deployment file online based on your business requirements. For example, you can configure parameters such asspec.template.spec.containers.livenessProbe
andspec.template.spec.containers.readinessProbe
.The following table describes the YAML fields that you must modify based on your business requirements.
NoteWhen you create a scaling configuration, the
spec.replicas
field does not take effect even if you configure it in your YAML file.No.
Field
Description
①
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 VPC, vSwitch, and Security Group based on your business requirements. After you complete the configuration, the system automatically incorporates the extended annotations into the YAML file displayed on the left.
NoteIf you do not specify a VPC or vSwitch, Auto Scaling uses the default VPC and default vSwitch. If no default VPC or default vSwitch exists, Auto Scaling creates one. For more information, see Default VPCs and default vSwitches.
Click Create. In the Confirm Information message, confirm the information and click Confirm.
In the Enable Scaling Configuration message, click OK.
Step 2: Check whether the scaling configuration takes effect
On the Instance Configuration Sources tab, view the details of the created scaling configuration.
Trigger a scale-out event to check whether any elastic container instances are created.
In this example, change the value of Expected Number of Instances for the scaling group to 2 to trigger a scale-out event and check whether Auto Scaling creates two elastic container instances as expected.
NoteFor information about how to view elastic container instances that are scaled out in a scaling group, see View instances in a scaling group.
(Optional) Step 3: View and download the YAML file
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 configuration from the YAML file. For more information, see ApplyEciScalingConfiguration.