All Products
Search
Document Center

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

Last Updated:May 30, 2024

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.

Container images: key points to remember

When utilizing various container images, take note of the following key points for optimal management and deployment:

  • Images residing in VPCs: You can download container images in a virtual private cloud (VPC) network setup, thereby eliminating your reliance on Internet connectivity.

    • General images: You can download and use the general images provided by Alibaba Cloud in a VPC network setup.

      Note

      If you want to use an Alibaba Cloud image, you must choose the image address based on your actual region. For example, if your region ID is cn-beijing, you can pull images only from the registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:latest address.

    • Private images: You can use an image that is hosted in a Container Registry repository. However, you must obtain the required permissions before you can pull your desired image from the Container Registry repository in a specified VPC.

  • Public images: You can download a public image from the Internet. You can use one of the following methods to enable Internet access for containers:

    • Enable SNAT for VPCs: After you create an Internet NAT gateway, you can enable the SNAT feature for your VPC to allow Internet access for containers residing in the VPC. This method is recommended. For more information, see Create and manage SNAT entries.

      Scenario: This method is applicable if your containers rely on load balancers to provide external services.

    • Associate elastic IP addresses (EIPs) with containers: You can enable the EIP feature when you configure a Kubernetes YAML file.

      Scenario: This method is applicable if your containers have the Internet access capability and can independently provide external services. We recommend that you use this method in single-node scenarios.

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.

    Note

    For 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

  1. Log on to the Auto Scaling console.

  2. In the top navigation bar, select the region where Auto Scaling is activated.

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

  4. In the upper-left corner of the Scaling Groups page, click Create.

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

    YAML文件.png

    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 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 Scaling Group Name, Minimum Number of Instances, Maximum Number of Instances, VPC, vSwitch, and Security Group based on your business requirements.

    Note

    After you complete the configuration, the system automatically incorporates the extended annotations into the YAML file displayed on the left.

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

    伸缩组创建.png

Step 2: Verify the expected number of container instances in the scaling group

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

    image

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

    image

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

  1. Find the scaling group that you created and click Details in the Actions column.

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

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

    image

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