This topic describes how to use Logical Host Colocation (LHC) to publish a locally developed unitized application to deployment units in two data centers.
This topic applies only to public cloud and Apsara Stack environments of AntStack 2.2 or later.
Step 1: Create a namespace
Log on to the console. In the navigation pane on the left, click Cluster Management > Namespace.
Click Create to open the Create Namespace page. Enter the following information and click Create.
Name: Enter a name for the namespace, such as
antcloud-demo. The default name is prefixed withTenantName+WorkspaceGroupIdentity.Add Tag: Add a custom tag to the namespace.
Step 2: Create applications
You will create three applications: txnflow, acccenter, and pointcenter.
Log on to the Application Management console. In the navigation pane on the left, click Application List.
On the Application List page, click Create Application.
On the Create Application page, enter the following information and click Submit.
Application Name: Enter names for the three applications:
txnflow,acccenter, andpointcenter.NoteThe application name must be unique within the same tenant.
Technology Stack: Select Spring Boot.
Application Group: Select an existing application group. If you have not created one, you can use the default group.
Application Tag: No tag is needed for this example.
Application Description: No description is needed for this example.
Step 3: Prepare an image
LHC deploys application services from images. Before you create an application service, you must build an image. After you develop the application, you can build the image in the LHC console. For more information, see Develop a unitized application and Build an image.
Step 4: Create application services
Create three application services with dependencies: txnflowsvcdemo, pointcenter-demo, and accountcentersvc-demo.
Log on to the console. In the navigation pane on the left, click Publishing and O&M > Application Service.
On the application service list page, click Create Application Service.
On the Create Application Service page, enter the following basic information and click Next.
Namespace: Select the namespace that you created in Step 1.
Application Service Name: The name of the container service. The instance name can contain lowercase letters, digits, and hyphens. It must start with a letter and end with a letter or digit. The name must be unique within the same namespace. Enter the following names for the three application services:
txnflowsvcdemo,pointcenter-demo, andaccountcentersvc-demo.Associated Application: Select an application to associate with the container service.
Application Service Name
Associated Application
txnflowsvcdemo
txnflow
pointcenter-demo
pointcenter
accountcentersvc-demo
acccenter
Description: Optional. The description of the container service.
On the Pod Template Configuration page, enter the following information and click Next.
The configuration for
txnflowsvcdemois as follows:Container Name: Enter a name.
Image Selection: Select Build Record and choose the build record from Step 3: Prepare an image.
CPU Configuration: Set Requested Cores to 1 core and Maximum Cores to 2 cores.
Memory Configuration: Set Requested Memory to 1 GiB and Maximum Memory to 2 GiB.
In Advanced Configuration > Environment Variable Configuration, add the required environment variables for the txnflowsvcdemo application service.
Configuration Overwrite: Add the required overwrite configurations for the txnflowsvcdemo application service.
The configuration for
pointcenter-demois as follows:Container Name: Enter a name.
Image Selection: Select Build Record and choose the build record from Step 3: Prepare an image.
CPU Configuration: Set Requested Cores to 1 core and Maximum Cores to 2 cores.
Memory Configuration: Set Requested Memory to 1 GiB and Maximum Memory to 2 GiB.
In Advanced Configuration > Environment Variable Configuration, add the required environment variables for the pointcenter-demo application service.
Configuration Overwrite: Add the required overwrite configurations for the pointcenter-demo application service.
The configuration for
accountcentersvc-demois as follows:Container Name: Enter a name.
Image Selection: Select Build Record and choose the build record from Step 3: Prepare an image.
CPU Configuration: Set Requested Cores to 2 cores and Maximum Cores to 4 cores.
Memory Configuration: Set Requested Memory to 4 GiB and Maximum Memory to 6 GiB.
In Advanced Configuration > Environment Variable Configuration, add the required environment variables for the accountcentersvc-demo application service.
Configuration Overwrite: Add the required overwrite configurations for the accountcentersvc-demo application service.
On the Elastic Configuration page, enter the following information and click Next.
Replica Scaling Policy Configuration: Currently, only Fixed Number of Replicas is supported. The default value is 0. Select the deployment units (
RZ01AandRZ02A) and change the number of replicas to 1. This ensures that the application service maintains a fixed number of pod replicas at runtime.On the Access Configuration page, enter the following information and click Next.
Application services support two access methods: load balancing and unified access. Load balancing is port-based. Unified access is rule-based.
Set the public network access method for the txnflowsvcdemo service
NoteYou do not need to add a service for the pointcenter-demo and accountcentersvc-demo services.
You can set the access method when you create the application service, or you can add it after the service is created.
On the Access Configuration page, click Add Load Balancer. Enter the following information and click Submit.
Load Balancer Name: Enter
txnflowsvcdemo.Access Method: Select Public Network.
Port Mapping: Click Add Port Mapping and enter the following information. Keep the default settings for the other parameters.
Protocol: Select http.
Forwarding Rule: Select Round Robin.
Frontend Port: The port that the workload in the container image listens on. The port range is from 1 to 65535.
Backend Port: The port on the Server Load Balancer instance to which the container port is mapped. This port is used to access the workload using the Server Load Balancer IP address. The port range is from 1 to 65535.
On the Deployment and Scheduling Configuration page, keep the default system configurations for all application services and click Next.
On the application service Preview page, confirm that the information is correct and click Submit.
Step 5: Create a release ticket
Use a release ticket to simultaneously publish the three application services that you created in the previous step.
Log on to the console. In the navigation pane on the left, click Publishing and O&M > Application Publishing.
Click Release Ticket to open the release and deployment dashboard.
On the release and deployment dashboard, click Create Release Ticket.
On the Create Release Ticket page, enter the following release information and click Next.
Basic Information
Title: The title of the release. For example,
Demodeploy.Type: Only group publishing is supported.
Namespace: Select the namespace where the application services to be published reside.
Application Service Publishing List: In the Available Application Services list, select the required application services. Click the > icon to add the services to the Selected Application Services list.
NoteIf an application service has multiple committed versions, you must select the version to publish. The latest version is selected by default.
Advanced Configuration
Set Application Service Dependencies: No configuration is needed.
On the Preview page, confirm that the information is correct and click Create. You are automatically redirected to the Release Ticket Details page. Click Publish All to start the release.
After the release order is created, the system automatically opens the Release Order Details page, where you can view its execution details.