All Products
Search
Document Center

:Migrate Spring Cloud applications from open source Nacos instances to MSE Nacos instances

Last Updated:Jul 05, 2023

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.

Note
  • 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

Note In this topic, a set of applications deployed in a Container Service for Kubernetes (ACK) cluster is used to describe how to migrate applications. If you understand the scenarios of application migration from an open source Nacos instance, you can implement the solution that is described in Migration solution.

Initial business

In an ACK cluster, a service provider application and a service consumer application are deployed. The service consumer application obtains the endpoint of the service provider application from the registry and obtains the port number of the service provider application by using the URL /user/rest. 1
Deploy the service consumer, service provider, and nacos-server applications in the ACK cluster. For more information, see Create a stateless application by using a Deployment. 2
Configure services in the ACK cluster. 3
  • 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

A consumer-new application is deployed and is registered with an MSE Nacos instance. The consumer-new application and the service consumer application use two different tags. Compared with the configuration of the consumer application, the configuration of the consumer-new application is similar, except for the endpoint. For the consumer application, the endpoint of the open source Nacos instance is used. For the consumer-new application, the endpoint of the MSE Nacos instance is used.4

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.

5

Step 1: Install the ack-onepilot component of Microservices Governance in an ACK cluster

  1. Log on to the ACK console.

  2. In the left-side navigation pane, choose Marketplace > Marketplace.

  3. On the App Catalog tab, search for the ack-onepilot component. If the component card is displayed, click the card.

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

    Note

    We recommend that you use the default namespace ack-onepilot.

  5. Click OK.

Step 2: Enable Microservices Governance for applications

  1. Log on to the MSE console and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > O&M Center > K8s cluster list.

  3. Find the cluster that you want to manage, and click Manage in the Actions column.

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

  1. Log on to the ACK console.

  2. 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.
  3. In the left-side navigation pane of the Cluster Information page, choose Workloads > Deployments. On the Deployments page, select a namespace from the Namespace drop-down list.
  4. Find the application that you want to manage and click Edit in the Actions column.
  5. 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.

    TypeVariable KeyValue/ValueFrom
    Customenable_multi_nacostrue
    Note This variable value indicates that the dual registration and dual subscription features are enabled.
    Customadditional_nacos_addressnacos-server:8848
    Note This variable value is the endpoint of the MSE Nacos instance.
    Customadditional_nacos_namespacee5bdc7e1-xxxx-4e2b-906d-b47b8efeee8b
    Note Optional. If this variable is not configured, the default namespace of the MSE Nacos instance is used.
Note

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.

  1. Log on to the open source Nacos console.
  2. In the left-side navigation pane, choose Service Management > Services. 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.

In this example, the consumer-new application is used to call the service provider application. You can enter http://Public endpoint of the consumer-new application/user/rest in the browser and press Enter to view the service call result. 6

Other settings

Configure other Nacos parameters

If the additional_nacos_address and additional_nacos_namespace parameters do not meet your configuration requirements for Nacos properties, you can use the following configuration to configure Nacos properties:
additional_nacos_properties=com.alibaba.nacos.naming.log.filename=/home/admin&com.alibaba.nacos.naming.log.level=warn
Note additional_nacos_properties is the variable that you need to configure. com.alibaba.nacos.naming.log.filename=/home/admin and com.alibaba.nacos.naming.log.level=warn are variable values. The variable values are separated by an ampersand (&). If you want to configure multiple variable values, you can connect the variable values by using ampersands (&).

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