Enterprise Distributed Application Service (EDAS) is seamlessly integrated with launch templates. In scenarios such as application creation, scale-outs, and auto scaling, you can use a launch template as a blueprint to create resources for Elastic Compute Service (ECS) clusters in EDAS. This helps you create resources in an efficient manner. This topic describes how to create an ECS instance by using a launch template.
Background information
A launch template persists the configurations of ECS instances and helps you create ECS instances in a few steps. For more information, see Create a launch template. A launch template contains the configurations that you can use to create instances. Except for passwords, launch templates can contain instance configurations, such as key pairs, Resource Access Management (RAM) roles, instance types, and network settings. You cannot modify a launch template. However, you can create multiple versions for each launch template and configure different parameters for each version. Instance configurations are updated with versions. You can create template versions and use a specific version to create an instance. For more information, see Create a launch template version.
Regardless of whether you create an instance in EDAS by using a launch template or based on existing instance specifications, the instance that you purchase from ECS uses the pay-as-you-go billing method. For more information, see Pay-as-you-go. After you release an instance, the billing rules vary based on the reclaim mode that you select when you create the instance. The following reclaim modes are supported:
Release Mode: After an application is scaled in, EDAS automatically releases the instance that is no longer used. You need to only pay for the instance during its service period.
Shutdown and Reclaim Mode: After an application is scaled in, the instance that is no longer used is stopped. You are not charged for the CPU and memory resources. However, you are still charged for the disks such as system disks and data disks, elastic IP address (EIP), and bandwidth. The public IP address is recycled and reassigned upon instance startup, and the EIP is retained. You are charged only a small amount of fees to retain the instance.
When EDAS directs you to the ECS console to configure the logon credentials for a launch template, we recommend that you use an SSH key pair. For more information, see Overview. A key pair is more secure than a common password because a key pair can prevent brute-force attacks. A key pair can also prevent other people from deducing a private key from a public key. If you want to control the access between ECS instances or between an ECS instance and a cloud service in EDAS, we recommend that you use a security group. For more information, see Overview. If you configure a security group when you create an ECS launch template, the ECS instances that you create by using the template in EDAS belong to the security group. Therefore, you can configure security group rules to control access permissions on the ECS instance.
Prerequisites
A launch template is created. For more information, see Create a launch template.
The created launch template and your application must reside in the same virtual private cloud (VPC). Otherwise, you cannot select the launch template in EDAS.
When you select a VPC for the launch template, you must select a vSwitch. Otherwise, you cannot select the launch template in EDAS.
Limits
You can use launch templates in EDAS to create instances only for ECS clusters, and not for Kubernetes clusters.
Method 1: Add an instance by using a launch template when you create an application
Log on to the EDAS console.
In the left-side navigation pane, choose .
On the Applications page, select a region in the top navigation bar. In the upper part of the page, select a microservices namespace. Then, click Create Application in the upper-left corner of the page.
In the Basic Information step, configure the Cluster Type, Application Runtime Environment, Application Name, and Application Description parameters. Then, click Next. The Application Description parameter is optional.
Cluster Type: Select ECS Clusters. This is because you can use a launch template to purchase an ECS instance only for ECS clusters.
Application Runtime Environment: The valid values are Java, Tomcat, and EDAS-Container (HSF). In this example, select EDAS-Container (HSF).
In the Configurations step, configure the deployment package and the instance source parameters, and click Next.
Network and environment resources
If you do not have network and environment resources, such as VPCs, microservices namespaces, or clusters, EDAS creates a default microservices namespace and cluster.
If you have created network and environment resources, such as VPCs, microservices namespaces, and clusters, you can select resources from drop-down lists in the EDAS console. You can select the required resources from the relevant drop-down lists.
Instance Source: In this section, select Purchase Instance. Then, select Purchase Based on Instance Launch Template as Purchase Method.
In the Select a launch template section, select the template and template version that you want to use for the instance from the drop-down lists. If no launch template is available, you can create a launch template in the ECS console. For more information, see Create a launch template.
Configure the Recycling Mode parameter.
Quantity: Specify the number of instances that you want to purchase, such as 1.
Terms of Service: Read and select Elastic Compute Service Terms of Service | Terms of Service for Images.
In the Advanced Settings step, configure the Version and Application Health Check parameters. Then, click Create Application. The Application Health Check parameter is optional.
Version: You can use the current timestamp as the version in a format such as yyyy-mm-dd hh:mm:ss. You can also specify a version in a different format.
Application Health Check: (Optional) Specify the URL that is used to check whether the application is healthy.
In the Creation Completed step, confirm the information in the Basic Information, Configurations, and Advanced Settings sections and click Create Application.
Method 2: Add an instance by using a launch template when you manually scale out an application
Log on to the EDAS console.
In the left-side navigation pane, choose . In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.
In the upper-right corner of the application details page, click Scale Out. In the Add Instance dialog box, specify the Target Group parameter in the Scale-out Method step.
Select Purchase Based on Instance Launch Template for the Scale-Out Method parameter.
Select a launch template and a template version that you want to use, specify the Recycling Mode parameter, and then click Next.
Use Bound Template: Use a launch template that you associate with the application instance group. Before you use a launch template, you must associate it with the selected application instance group. For more information, see Associate a launch template with an application instance group.
Use Specified Template: Use a template that you create in the ECS console. If you have created multiple templates in the ECS console, you can select a template and a template version that best suit your business needs.
In the Purchase Details step, set the Quantity parameter, select Elastic Compute Service Terms of Service | Terms of Service for Images, and then click Next.
In the Confirm step, check the quantity of ECS instances to be purchased and the information about the instance launch template. Verify all the information and click Confirm.
In the upper part of the page, the Automatic purchasing is triggered. Check the real-time information in the application change process message appears.
Method 3: Add an instance by using a launch template in the auto scaling module of the EDAS console
You can add instances by using launch templates in the auto scaling module of the EDAS console only for High-Speed Service Framework (HSF) applications in ECS clusters.
Log on to the EDAS console.
In the left-side navigation pane, choose . In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.
In the left-side navigation pane of the application details page, click Auto Scaling.
In the upper-right corner of the Scale-out Rule section, turn on the switch.
Configure the parameters of the scale-out rule and click Save.
Parameter
Description
Trigger Metrics
Specify the thresholds of RT, Load, and CPU. When a threshold is exceeded, a scale-out is triggered.
Trigger Conditions
Any One of the Metrics: A scale-out is triggered when the value of one of the configured metrics exceeds the specified threshold.
All Metrics: A scale-out is triggered only when the values of all configured metrics exceed the specified thresholds.
Last for More Than
The duration during which the metric value repeatedly exceeds the threshold. Unit: minutes. If the average value of a metric repeatedly exceeds the specified threshold every minute within the duration, a scale-out is triggered. You can configure the duration based on the sensitivity of the cluster service capabilities.
Application Source
Select Elastic Resources.
Creation Method: Select Purchase Based on Instance Launch Template.
Launch Template: Click Select Template. In the Select a launch template dialog box, select the template and template version that you want to use for the instance, configure the Recycling Mode parameter, and then click OK.
Terms of Service: Read and select Elastic Compute Service Terms of Service | Terms of Service for Images.
Advanced Options: If you turn on the switch, you can configure the Network Type and Multi-zone Scaling Policy parameters.
Network Type: Specify the network in which your application resides. You cannot change the network after you complete the configurations. If the application resides in a VPC, you must specify the vSwitch that you want to connect to the new instance. If you specify multiple vSwitches, EDAS automatically allocates vSwitches based on the multi-zone scaling policy.
Multi-zone Scaling Policy: Select Priority Policy or Balanced Distribution Policy.
Number of Instances to Add for Each Scale-Out
The number of instances that are automatically added after each scale-out is triggered. Specify this parameter based on the service capabilities of each instance.
Maximum Number of Instances in Group
The maximum number of instances in the cluster. If the number of instances in the cluster reaches the parameter value, a scale-out is no longer triggered. Specify this parameter based on your resource limit.
Verify the result
After you add an instance by using a launch template based on one of the preceding methods, view the number and status of the application instances on the Instance Information tab of the application details page.
References
Add ECS instances to an application that is deployed in an ECS cluster: This topic provides three methods to manually scale out applications to balance the loads of application instances.
Perform auto scaling on applications in ECS clusters: This topic describes how to dynamically adjust the number of application instances by using the auto scaling feature to balance loads of the application instances.