In the Auto Scaling console, you can create an Elastic Container Instance (ECI) scaling configuration from a Kubernetes YAML file to quickly deploy services. This scaling configuration serves as a template for creating ECI instances during scale-out events. This approach frees you to focus on application development instead of managing underlying nodes and clusters, improving development efficiency.
Prerequisites
-
You have created an ECI scaling group. For more information, see Configure a scaling group for ECI by using a Kubernetes YAML file.
-
A container image has been selected for deployment.
You can use a public image provided by Alibaba Cloud. This topic uses
registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latestas an example. Replace the image with the container image address for your workload as needed.
Limits
-
You can create an ECI scaling configuration only from a Kubernetes Deployment YAML file.
Because the underlying implementation does not rely on a Kubernetes cluster, Kubernetes cluster-related fields are not supported and have no effect when you create a scaling configuration. Only YAML fields within the Kubernetes Deployment resource are supported.
-
In addition to native Kubernetes resource fields, you can specify configuration options for an ECI instance by setting annotations in the
metadata.annotationsfield of the YAML file. For example, you can define the Virtual Private Cloud (VPC), vSwitch, and security group for your containers.NoteFor a list of supported YAML fields and annotations, see Supported YAML and annotation fields.
Procedure
Step 1: Create a scaling configuration from a Kubernetes Deployment
Log on to the Auto Scaling console.
In the navigation pane on the left, click Scaling Groups.
In the top navigation bar, select a region.
Find the scaling group that you want to manage and open its details page in one of the following ways:
In the Scaling Group Name/ID column, click the ID of the scaling group.
In the Actions column, click Details.
At the top of the page, click the Scaling Configurations tab.
-
On the Scaling Configuration tab, click Create Scaling Configuration.
-
Click the Create by YAML File tab and edit the YAML file.
This example is for reference only and uses the
registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latestimage. You can customize the Kubernetes Deployment YAML content online based on your business requirements. For example, you can set parameters such asspec.template.spec.containers.livenessProbeorspec.template.spec.containers.readinessProbe.The following table describes the parameters that you need to modify.
NoteThe
spec.replicasfield in the YAML file is ignored.No.
Parameter
Description
①
imageThe container image.
For example, replace the sample public image with the URI of your image in the corresponding VPC. In this case, change the value of
imagetoregistry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest.②
annotationsExtended annotations.
In the Edit Extended Fields panel on the right, select a VPC, a vSwitch, and a security group. When you configure these fields in the panel, the corresponding annotations are automatically added to the YAML file.
NoteIf you do not specify a VPC and a vSwitch, Auto Scaling uses or creates a default VPC and a default vSwitch. For more information, see Default VPCs and vSwitches.
-
Click Create. In the confirmation dialog box, verify the settings and click Create Order.
-
In the Apply Scaling Configuration dialog box, click OK.
Step 2: Verify the scaling configuration
-
On the Instance Configuration Source tab, view the details of the newly created scaling configuration.
Verify that the Status column of the newly created scaling configuration shows Active, indicating that the scaling configuration is ready for scale-out events.
-
Trigger a scale-out event to verify that the ECI instances are created.
For example, change the scaling group's expected number of instances to 2 to trigger a scale-out event. Then, verify that two ECI instances are automatically created.
NoteTo view the ECI instances that are created during a scale-out event in a scaling group, see View the list of instances in a scaling group.
On the Auto Created tab of the Instance List, verify that all instance statuses show In Service and healthy, confirming that ECI instances were successfully created and the scaling configuration is working.
(Optional) Step 3: View and download the YAML file
-
At the top of the page, click the Instance Configuration Source tab.
-
In the list of scaling configurations, find the target scaling configuration and click Actions in the View YAML column.
The dialog box shows the complete YAML configuration that is in effect.
apiVersion: apps/v1 kind: Deployment metadata: annotations: {} name: nginx-demo spec: template: metadata: annotations: k8s.aliyun.com/eci-vswitch: vsw-bxxxxxxxxxxxned k8s.aliyun.com/eci-security-group: sg-bxxxxxxxxxxxxx1aj k8s.aliyun.com/eci-use-specs: 2.0-4.0Gi k8s.aliyun.com/eip-bandwidth: '5' k8s.aliyun.com/eci-with-eip: 'true' spec: containers: - image: registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest lifecycle: {} livenessProbe: {} name: nginx readinessProbe: {} -
Click Download.
The file is saved locally with a
.yamlextension.
Related documentation
To create and manage a scaling configuration from a YAML file by using the API, see ApplyEciScalingConfiguration - Manage a scaling configuration based on a configuration file.