Microservices Engine (MSE) provides managed Nacos instances. The managed Nacos instances provide more powerful and stable features than open source Nacos instances. You do not need to maintain Nacos instances in MSE. This allows you to focus on your business. You can also obtain expert support if you use MSE Nacos Professional Edition. This topic describes how to smoothly migrate Spring Cloud applications from an open source Nacos instance to an MSE Nacos instance.
Prerequisites
A Nacos instance is created. For more information, see Create a Nacos instance.
If your instance needs to be accessed only by applications in a VPC, you need only to create a VPC.
If your instance needs to be accessed by applications in different VPCs, you need to enable Internet access. A public IP address whitelist is required for Internet access. If a public IP address whitelist is left empty, all public IP addresses can be used to access your instance over the Internet. For more information, see Configure a public IP address whitelist.
For Spring Cloud applications, the solution supports dual subscription for consumers that use the Ribbon load balancing component. Dual subscription is not supported for consumers that use the Spring Cloud LoadBalancer component.
Background information
Initial business
- The consumer service is a LoadBalancer service. You can directly access the consumer service by using Server Load Balancer (SLB).
- The nacos service is a LoadBalancer service. You can directly access the open source Nacos console by using SLB.
- The nacos-server service is a NodePort service. After you configure the nacos-server service, the service consumer application and the service provider application can directly access the nacos-server service by accessing the endpoint http://nacos-server:8848/ .
If the service call is successful, log on to the open source Nacos console and view the information about service registration.
Simulate the migration process
In addition, a LoadBalancer service is configured in the ACK cluster to access the consumer-new application.
Existing issues
The consumer-new application cannot call the service provider application. You can query the consumer-new application from the MSE Nacos instance but not from the open source Nacos instance. This is because the consumer-new application is not registered with the open source Nacos instance.
In actual business scenarios, if a new application cannot access the application in the open source Nacos instance, you may fail to migrate the new application. When a large number of applications are involved and the application calls are complex, this issue is more likely to occur. Therefore, you must migrate the applications to the MSE Nacos instance first.
Migration solution
MSE Nacos instances use Java agents to migrate applications. After you migrate your applications to MSE Nacos instances, you can use the instances to manage your microservice applications without the need to modify code and configurations. The following figure shows the migration architecture.
Step 1: Install the ack-onepilot component of Microservices Governance in an ACK cluster
Log on to the ACK console.
In the left-side navigation pane, choose .
On the App Catalog tab, search for the ack-onepilot component. If the component card is displayed, click the card.
In the upper-right corner of the ack-onepilot page, click Deploy. In the Basic Information step of the Deploy wizard, select a cluster from the Cluster drop-down list and a namespace from the Namespace drop-down list, specify Release Name, and then click Next.
NoteWe recommend that you use the default namespace ack-onepilot.
Click OK.
Step 2: Enable Microservices Governance for applications
Log on to the MSE console and select a region in the top navigation bar.
In the left-side navigation pane, choose .
Find the cluster that you want to manage, and click Manage in the Actions column.
- On the cluster details page, find the namespace that you want to manage, and click Activate Microservices Governance in the Operation column. In the message that appears, click OK.
Step 3: Enable the seamless migration feature for the open source Nacos instance
Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters. On the Clusters page, find the cluster in which your application is deployed and click the cluster name.
- In the left-side navigation pane of the Cluster Information page, choose . On the Deployments page, select a namespace from the Namespace drop-down list.
- Find the application that you want to manage and click Edit in the Actions column.
- In the Environment Variable section of the Edit page, click Add, add the environment variables that are described in the following table, and then click Update.
The following table describes the environment variables.
Type Variable Key Value/ValueFrom Custom enable_multi_nacos true Note This variable value indicates that the dual registration and dual subscription features are enabled.Custom additional_nacos_address nacos-server:8848 Note This variable value is the endpoint of the MSE Nacos instance.Custom additional_nacos_namespace e5bdc7e1-xxxx-4e2b-906d-b47b8efeee8b Note Optional. If this variable is not configured, the default namespace of the MSE Nacos instance is used.
During the actual migration process, we recommend that you activate MSE and configure environment variables when you create an application. This way, you do not need to enable related features repeatedly. The migration solution is not fully released in MSE. If you want to use the solution, join the DingTalk group (ID: 34754806) to contact technical support.
Verification
Verify the service registration result.
- Log on to the open source Nacos console.
- In the left-side navigation pane, choose . The service is registered and the details of the service can be queried.
Verify the timeliness of service registration
Scale in or scale out the application to verify the timeliness of service registration. In this example, if you increase the number of the instance of the consumer-new application to 4, the services are registered and deactivated in real time.
Verify the service call result.
Other settings
Configure other Nacos parameters
additional_nacos_properties=com.alibaba.nacos.naming.log.filename=/home/admin&com.alibaba.nacos.naming.log.level=warn
Registration only without subscription/Subscription only without registration
- If you want to subscribe to services without registering the services, add the following parameter:
additional_nacos_properties=subscribeOnly=true
- If you want to register services without subscribing to the services, add the following parameter:
additional_nacos_properties=registerOnly=true