All Products
Search
Document Center

Auto Scaling:Use Kubernetes YAML files to configure scaling configurations of the Elastic Container Instance type

Last Updated:Sep 24, 2024

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.

    Note

    For 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

  1. Log on to the Auto Scaling console.

  2. In the left-side navigation pane, click Scaling Groups.

  3. In the top navigation bar, select a region.

  4. 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.

  5. In the upper part of the details page, click the Instance Configuration Sources tab.

  6. On the Scaling Configurations tab, click Create Scaling Configuration.

  7. 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 as spec.template.spec.containers.livenessProbe and spec.template.spec.containers.readinessProbe.

    yaml-伸缩配置.png

    The following table describes the YAML fields that you must modify based on your business requirements.

    Note

    When 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 the registry-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.

    Note

    If 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.

  8. Click Create. In the Confirm Information message, confirm the information and click Confirm.

    伸缩配置.png

  9. In the Enable Scaling Configuration message, click OK.

Step 2: Check whether the scaling configuration takes effect

  1. On the Instance Configuration Sources tab, view the details of the created scaling configuration.

    查看伸缩配置.png

  2. 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.

    Note

    For information about how to view elastic container instances that are scaled out in a scaling group, see View instances in a scaling group.

    ECI实例.png

(Optional) Step 3: View and download the YAML file

  1. In the upper part of the scaling group details page, click the Instance Configuration Sources tab.

  2. 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.

    查看YAML.png

  3. 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.