Getting started with MSE

更新时间:
复制 MD 格式

Microservices Engine (MSE) provides the following modules: Microservices Registry, Microservices Governance, and Cloud-native Gateway. When you develop your microservice system, you can use a single module or a combination of multiple MSE modules. This topic describes how to use a combination of MSE modules.

Overview

Introduction

This tutorial shows the core capabilities of MSE to help you quickly get started with and understand MSE modules. The estimated duration of the tutorial is 20 minutes. We recommend that you perform the following steps in sequence:

  1. Deploy the sample microservice application in a Container Service for Kubernetes (ACK) cluster or ACK Serverless cluster and register the microservice application with a Nacos instance.

  2. Configure and manage the microservice application in Microservices Registry.

  3. Use cloud-native gateways to expose services to the Internet.

  4. Implement end-to-end canary release for the application by using Microservices Governance.

Intended users

This tutorial is suitable for personnel who plan to use or extend cloud-native architectures on Alibaba Cloud. The personnel can be developers of microservice frameworks such as Spring Cloud and Dubbo, IT infrastructure architects, administrators, and DevOps personnel.

Overall architecture

  • Microservices Registry: provides fully managed Nacos, ZooKeeper, and Eureka instances to allow you to maintain and manage service nodes and configuration information in a centralized manner. Microservices Registry also provides comprehensive monitoring and alerting features, supports various engine types, and allows you to perform O&M in the MSE console. Compared with open source components, Microservices Registry provides higher performance, service-level agreement (SLA) assurance, and configuration capabilities.

  • Cloud-native Gateway: provides secure and efficient next-generation gateways that comply with Kubernetes Ingress standards and integrates Ingress traffic gateways, microservice gateways, and security gateways.

  • Microservices Governance: improves open source microservice frameworks, such as Spring Cloud and Apache Dubbo, without code changes. Microservices Governance provides various service governance and traffic protection features to decouple middleware from business. Microservices Governance provides governance capabilities such as circuit breaking, throttling, degradation, graceful start and shutdown, and end-to-end canary release. This helps improve development efficiency and online stability.

Limits

Note

The following table describes the limits on the items in this tutorial to simplify the procedure. The limits apply only to this tutorial. For more information about MSE features, see Features.

Item

Limit

Remarks

Cluster

You can deploy applications only in ACK clusters or ACK Serverless clusters, but not Elastic Compute Service (ECS) instances.

Note

Minimum configurations for running demo applications in an ACK cluster or ACK Serverless cluster:

  • Configure SNAT: Do not select this item.

  • Access to API server: Select the Server Load Balancer (SLB) instance with the smallest specifications. Do not select Expose API server with EIP.

  • Security Group: Select Create Advanced Security Group.

  • Instance Type: The demo application requires four pods. One pod requires 0.25 vCPUs and 128 MB of memory. No requirements are imposed on the system disk.

  • Ingress: Select Do Not Install.

  • Log Service: We recommend that you select Enable Log Service.

You can apply for the one-month free trial of ACK Serverless clusters.

Microservices Registry

Only the MSE Nacos engine type is supported and is required. You can select a version and a billing method of MSE Nacos instances based on your business requirements.

Note

Minimum configurations:

  • Product Version: Select Developer Edition.

  • Engine Specifications: Select 1 Core, 2 GB Memory.

  • Public Bandwidth: Set this parameter to 0.

You can apply for the one-month free trial of Microservices Registry.

Cloud-native Gateway

We recommend that you use gateways of V1.2.13 or later.

Note

Minimum configurations:

  • Gateway Engine Specifications: Select 2 Cores, 4 GB.

  • Gateway Nodes: Set this parameter to 1.

  • vSwitch Location: Select Optional Zone.

  • Select an instance with the smallest specifications for Internet SLB Specifications. You do not need to specify Intranet SLB Specifications.

  • Security Group Type: Select Advanced Security Group.

  • We recommend that you select Log Service. Do not select Tracing Analysis.

You can apply for the one-month free trial of cloud-native gateways.

Microservices Governance

Only the end-to-end canary release feature is available. For more information about other features, see Features.

Note

You must select Professional Edition or an advanced edition for Edition.

You can apply for the one-month free trial of Microservices Governance.

VPC

You must deploy the cluster, Microservices Registry instance, and cloud-native gateway in the same virtual private cloud (VPC).

The cluster, Microservices Registry instance, and cloud-native gateway must connect to each other.

vSwitch

If you want applications to be automatically deployed, you must make sure that vSwitches exist in the specified region and zone.

If you manually deploy applications, you do not need to take note of this limit.

Demo application

Two demo applications are required: a consumer and a provider. Each demo application has the base version and canary version.

You can go to GitHub to view the demo applications.

Step 1: Deploy microservice applications

The microservice applications that you want to deploy are implemented based on Spring Cloud and Dubbo. The consumer calls the provider. You can obtain the demo code from GitHub and compare the demo code with your actual development code.

Note

You do not need to download the demo code. The demo image is generated and uploaded to the public image repository.

Deploy the microservice applications

  1. Log on to the MSE console.

  2. In the Deploy Microservice Application section, configure parameters.

    1. ACK/ACK Serverless Cluster: Select a cluster from the ACK/ACK Serverless Cluster drop-down list. If no cluster is available, click Go to Create to create a cluster. For more information about how to create a cluster, see Create an ACK managed cluster.

      Note
      • You can create an ACK or ACK Serverless cluster and specify a peak bandwidth based on your business requirements.

      • You must deploy the cluster in the same region and VPC as your Nacos instance.

    2. Select Nacos: Select an instance from the Select Nacos drop-down list. If no MSE instance is available, click Go to Create to create an MSE instance. For more information about how to create an MSE Nacos instance, see Create a Nacos engine.

      Note
      • The engine type of the MSE instance must be Nacos.

      • The network type of the MSE instance must be VPC, and you must deploy the MSE instance in the same VPC as your cluster.

      • The other configuration items of the MSE Nacos instance, such as Product Version, Engine Specifications, and Number of Cluster Nodes, are not limited.

    3. Application Deployment: Click Go to Deploy to the right of Application Deployment.

      The following table provides the regions and zones that support automatic deployment.

      Region

      Region ID

      Zone

      Asia Pacific - China

      China (Hangzhou)

      cn-hangzhou

      k, j, i

      China (Shanghai)

      cn-shanghai

      b, g

      China (Qingdao)

      cn-qingdao

      b, c

      China (Beijing)

      cn-beijing

      g, h

      China (Zhangjiakou)

      cn-zhangjiakou

      a, b, c

      China (Hohhot)

      cn-huhehaote

      a, b

      China (Ulanqab)

      cn-wulanchabu

      a, b

      China (Shenzhen)

      cn-shenzhen

      e, d

      China (Guangzhou)

      cn-guangzhou

      a, b

      China (Chengdu)

      cn-chengdu

      a, b

      Asia Pacific - Others

      Singapore

      ap-southeast-1

      b

      Europe and Americas

      Germany (Frankfurt)

      eu-central-1

      a, b

      • If you select Automatic Deployment, click OK.

        Note
        • If Automatic Deployment is dimmed, automatic deployment is not supported in the region and zone.

        • If you select Automatic Deployment, you must select a vSwitch in the specified zone and select Use PrivateLink. Then, PrivateLink creates temporary resources free of charge.

      • If you select Manual Deployment, follow the instructions in the console.

        1. Copy the YAML file in the demo and paste the file to the creation page. Click Copy YAML Code to Clipboard.

        2. Go to the Cluster Information page in the ACK console, and choose Workloads > Deployments. On the Deployments page, click Create from YAML.

        3. Replace all nacos-server fields in environment variables with the internal endpoint of your MSE Nacos instance.

          Note

          A total of five nacos-server fields in the YAML file must be replaced.

        4. Click Create to deploy the application.

    4. Check the deployment status.

      • If Deployed is displayed, click Next.

      • If Deploying is displayed, wait until the application is deployed.

      • If Deployment failed is displayed, the service is not found within 3 minutes. Troubleshoot the issue by following the instructions in Pod troubleshooting.

Operation result

Two demo applications are deployed in the ACK or ACK Serverless cluster and registered with the MSE instance.

Step 2: Query and configure microservices

  1. Query MSE Nacos services. The provider registers its information with Microservices Registry. The consumer queries services from Microservices Registry, obtains a list of service instances, and then calls a service that is deployed on an instance.

  2. Manage MSE Nacos instance configurations. The mechanism of dynamic refresh based on event listening is configured for Spring Cloud. The feature of listening to configurations is added to consumer code. The consumer continuously listens to the configuration file whose Data ID is consumer.properties and continuously logs the value of name in the configuration.

Query and configure microservices

  1. Go to the Microservices Query and Configuration section.

  2. Query services.

    1. Click the Service Management-Service list link in the Query services step.

    2. On the Services page, view information about the following services:

      • Two Spring Cloud services: consumer and provider

      • Two Dubbo services: providers:com.alibabacloud.mse.demo.service.HelloServiceB:1.0.0:

        consumers:com.alibabacloud.mse.demo.service.HelloServiceB:1.0.0:

  3. Publish configurations.

    1. Click the Configuration management-Configuration list-Create Configuration link. In the Add Configuration panel, configure the parameters.

    2. Set the Data ID parameter to consumer.properties and the Group parameter to DEFAULT_GROUP.

    3. Select Properties for Configuration Format.

    4. Enter name=demo in Description.

      Note
      • You can configure the name parameter based on your business requirements. For example, you can enter name=helloworld.

      • The consumer continuously listens to the configuration and logs the value of name.

    5. Click Release.

  4. Listen and query data.

    1. Click the Configuration management-Listening Query link in the Listen and query data step.

    2. On the Listener Query page, configure the Data ID and Group parameters, and click Query.

    3. Check the values of the IP and Push Status parameters in the returned result.

      Note
      • If Pushed is displayed in the Push Status column, the configuration takes effect.

      • If no result is returned, click Query multiple times or refresh the page and try again.

Operation result

The services that are registered with the MSE Nacos instance can be queried, a configuration is released, and the push status of the configuration can be queried.

Step 3: Expose services

MSE cloud-native gateways are next-generation gateways that are compatible with the Kubernetes Ingress standards. MSE cloud-native gateways integrate Ingress traffic gateways, microservice gateways, and security gateways to provide higher performance and higher security protection. In this step, you must use cloud-native gateways to expose services to the Internet and perform route debugging. The following operations are performed after a cloud-native gateway receives a request:

  1. The cloud-native gateway automatically identifies service names based on matched routes.

  2. The cloud-native gateway queries the instance nodes of the backend service from Microservices Registry.

  3. Microservices Registry returns the instance nodes, and the cloud-native gateway calls the backend service.

  4. The backend service returns the result to the cloud-native gateway, and the cloud-native gateway returns the result to the client.

Expose services

  1. In the 3.1 Basic configurations section, configure the parameters.

    1. Select a gateway: Select a gateway from the drop-down list. If no cloud-native gateway is available, click Go to Create to create a cloud-native gateway. For more information about how to create a cloud-native gateway, see Create an MSE cloud-native gateway.

      Note
      • When you create a cloud-native gateway, you must make sure that the gateway and the MSE Nacos instance are deployed in the same VPC.

      • You can configure the other configuration items, such as engine specifications, instance nodes, vSwitch, public bandwidth, and monitoring and alerting, based on your business requirements.

    2. Add a service source: Click the Service Management-Source management-Add Source link in the Add a service source step.

      1. In the Add Source panel, select MSE Nacos for Source Type.

      2. Set Cluster Name to the name of the MSE Nacos instance that you selected in Step 1: Deploy a microservice application. The Registration Type and Registration Address parameters are automatically configured and do not need to be modified.

      3. Click OK. Then, the service source is added.

    3. Add a service: Click the Service Management-Service list-Create service link in the Add a service step.

      1. In the Add Service panel, select MSE Nacos for Service Source.

      2. Set Namespace to public.

      3. In the Services section, add the consumer service on the left to the right.

        Note
        • You only need to add the consumer service to the gateway. The consumer automatically calls the provider.

        • If the consumer service that you want to add is unavailable, wait for 1 minute and try again.

      4. Click OK. Then, the consumer is added.

    4. Associate a domain name with the gateway: Click the Domain Names-Add Domain Name link in the Associate a domain name with the gateway step.

      1. In the Associate with Domain Name panel, set Domain Name to example.com and Protocol to HTTP.

        Note
        • This domain name is used only as the access entrance of test traffic, and no DNS resolution is configured.

        • In actual production, you must configure the DNS mapping between the domain name and the gateway SLB.

      2. Click OK. Then, a domain name is associated with the gateway.

  2. In the 3.2 Route configuration section, configure the parameters.

    1. Create a route: Click the Routes-Route Settings-Add Route link in the Create a route step.

      1. In the Add Route panel, configure the parameters in the Request Information step and click Next. The following table describes the parameters.

        Parameter

        Description

        Remarks

        Route Name

        Enter a name for the route.

        We recommend that you configure the name based on your business scenarios, such as user-default or user-gray.

        Domain Name

        Select the domain name example.com that is created in the previous step.

        The traffic source is http://example.com.

        Match Rule

        Select Exact Match for Path and enter /a.

        The entire Path parameter value is specified to match requests and a route. In the consumer code, the path /a is added. In this example, you can select Exact Match and set the Path value to /a.

        Method

        You do not need to configure this parameter.

        This parameter specifies the method for matching HTTP requests with a route. If you do not configure this parameter, requests with any Method value can match the route.

        Header

        You do not need to configure this parameter.

        This parameter specifies the Header parameter that is used to match HTTP requests with a route. In this example, you do not need to configure this parameter.

        Query Parameters

        You do not need to configure this parameter.

        This parameter specifies the Query parameter that is used to match HTTP requests with a route.

      2. Click Next. In the Destination Service step, configure the parameters. The following table describes the parameters.

        Parameter

        Description

        Remarks

        Destination Service

        Select Single Service.

        If you select Single Service, the cloud-native gateway forwards requests to a specific backend service.

        Service

        Select consumer from the drop-down list.

        The backend service consumer is associated.

        Port Number

        This parameter is automatically configured and does not need to be modified.

        The cloud-native gateway can automatically obtain the port number.

        Protocol

        This parameter is automatically configured and does not need to be modified.

        The cloud-native gateway can automatically obtain the service protocol.

        Configure Fallback Service

        Do not configure this parameter.

        If you select this item and no node is available for the destination service that is selected by the route, the original request accesses the configured fallback service.

      3. Click Save and Online.

    2. Perform route debugging: Click the Routes-Route Debugging link in the Perform route debugging step.

      1. On the Route Debugging page, select example.com, enter /a, and then click Send.

      2. Check whether A —> B is displayed on the Body tab. If yes, the route debugging is successful.

        Note
        • In this example, the route debugging is performed on the GET request from http://example.com/a.

        • It requires 2 minutes to load the route debugging component. If the expected result is not returned, you can refresh the page and click Send again.

Operation result

A service registered with the Nacos instance is added to the cloud-native gateway, and route configuration and route debugging are performed. The cloud-native gateway can route external requests to the consumer.

Step 4: Perform end-to-end canary release

In this step, MSE Microservices Governance is used to implement end-to-end canary release. In microservices scenarios, calls among applications are random. Traffic may be randomly routed to applications of canary versions, as shown in the left part of the following figure. To resolve the issue, you can use the end-to-end canary release feature to isolate specific versions of an application from other versions and route request traffic that matches specific rules, such as name=gray, to the desired version of the application. You can create lanes that are equivalent to independent runtime environments to isolate application versions and configure lane rules to route traffic.

Perform end-to-end canary release

  1. Configure parameters in the 4.1 Basic configurations section.

    1. Activate Microservices Governance: Click the Go to Activate link in the Activate Microservices Governance step.

    2. Enable Microservices Governance for the applications in the ACK cluster: Click the ACK Application Access link in this step. On the Application Governance page, click ACK Application Access.

      Note
      • If your applications are deployed in an ACK Serverless cluster, you must complete the authorization before you enable Microservices Governance for your applications.

      • You need to configure parameters in the dialog box that appears. For more information, see Enable Microservices Governance for microservice applications in an ACK cluster.

      • You must manually restart the applications. After the restart, the consumer and provider applications are available on the Application list page of Microservices Governance.

    3. Redeploy: Click the Redeploy link in this step.

    4. Edit the route: Click the Routes-Route Settings-Edit link in this step.

      1. On the Route Settings page, find the routing rule that you created in 3.2 Route configuration and click Edit in the Actions column.

      2. In the Edit Route panel, click Next. Then, select Tag-based Routing for Destination Service.

      3. Select consumer for Service and base for Version, and click Save and Release.

        Note
        • After a canary version is deployed for an application, all requests from /a are routed to the base version rather than the canary version.

        • Before you deploy a canary version in the production environment, you must make sure that tag-based routing is configured as the routing rule for the base application. This prevents traffic from being routed to the canary application.

    5. Deploy a canary application: Click the Go to Deploy link in this step. For more information, see Step 1: Deploy a microservice application.

      Note
      • In the YAML file that is used to deploy the canary version, alicloud.service.tag: gray indicates that the canary version is deployed for the specified application.

      • In the YAML file that is used to deploy the canary version, msePilotCreateAppName: consumer indicates that the canary application that is registered with Microservices Governance is consumer.

      • In the YAML file that is used to deploy the canary version, msePilotAutoEnable: 'on' indicates that Microservices Governance is enabled for the application.

  2. In the 4.2 End-to-end canary release section, configure the parameters.

    1. Create a lane group: Click the Create Lane Group link.

      1. On the Full link grayscale page, click Create Lane Group and Lane.

      2. In the create swimlane group panel, specify Lane Group Name, and select MSE Cloud-native Gateway for Gateway Type.

      3. Set Lane Group Traffic Entry to the cloud-native gateway that is specified in Step 3: Expose services.

      4. Select provider and consumer for All Lane Group Applications and click OK.

    2. Create a lane: Click the Create Lane link.

      1. On the Full link grayscale page, select the lane group that is created in the previous step.

      2. In the lower part of the page, click Create Lane. In the Create Lane dialog box, configure the parameters. The following table describes the parameters.

        Parameter

        Description

        Remarks

        Add Application

        Select gray from the Lane Tag drop-down list.

        The gray value is the same as the value of alicloud.service.tag in the code for the canary application.

        Routing Rule

        Move the tag-based routing rule from the left side to the right side.

        Only tag-based routing rules are displayed and can be selected.

        Conditions

        In the lower part of the Conditions section, click + Add Rule Condition to add a condition. In this example, set Parameter Type to Header, Parameter to name, Condition to exact-match, and Value to gray.

        Requests with name=gray in the header are routed to the canary application.

    3. Perform route debugging: Click the Routes-Route Debugging link.

      1. On the Route Debugging page, select the domain name example.com, and enter /a.

      2. On the Header tab, click Add Parameter.

      3. Set KEY to name and VALUE to gray, and click Send.

        Note
        • In this example, route debugging is performed on the GET request from http://example.com/a. The value of name in the request header is gray.

        • If Agray -> Bgray is displayed, end-to-end canary release takes effect, and traffic is always routed to the canary versions of the applications.

Operation result

You have completed MSE quick start. You can click Quick Start and evaluate MSE. Thank you for your support.

Step 5: Clear resources

We recommend that you manually clear resources each time you complete the quick start. Follow the steps to clear resources. If you change the order, resources may fail to be deleted. You can re-experience MSE only after you complete Step 4.

  1. Log on to the MSE console.

  2. Delete the resources that are related to Microservices Governance.

    1. In the left-side navigation pane, choose Microservices Governance > Full link grayscale.

    2. Select the lane group that you created.

    3. In the Traffic Distribution section, click Delete in the Operation column.

    4. In the Delete prompt message, click OK.

    5. Click the Configure icon to the right of Create Lane Group.

    6. In the lane group list, find the lane group that you want to delete, and click the image.png icon.

    7. In the Delete prompt message, click OK.

  3. Delete the resources that are related to Cloud-native Gateway.

    1. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. In the top navigation bar, select a region.

    2. On the Gateways page, click the name of the gateway whose resources you want to delete.

      1. Before you delete the route, unpublish the routing rule of the cloud-native gateway.

        1. In the left-side navigation pane, choose Routes > Route Settings.

        2. On the page that appears, find the route that you want to delete, click image.png in the Actions column, and then select Shutdown. In the Shutdown message, click OK.

        3. Find the route that is shut down, click the image.png icon in the Actions column, and then select Delete. In the Delete message, click OK.

      2. Delete services on the Service list page of the destination cloud-native gateway.

        1. In the left-side navigation pane, choose Services > Service list.

        2. On the page that appears, find the service that you want to delete and click Delete in the Actions column.

        3. In the Delete message, click OK.

      3. Delete service sources on the Source Management page of the destination cloud-native gateway.

        1. In the left-side navigation pane, choose Service Management > Sources.

        2. On the page that appears, find the service source that you want to delete and click Delete in the Actions column.

        3. In the Delete message, click OK.

      4. Delete the domain name of the destination cloud-native gateway.

        1. In the left-side navigation pane, click Domain Names.

        2. On the page that appears, find the domain name that you want to delete and click Delete in the Actions column.

        3. In the Delete message, click OK.

  4. Delete resources that are related to Microservices Registry.

    1. In the left-side navigation pane, choose Microservices Registry > Instances. In the top navigation bar, select a region.

    2. On the Instances page, click the name of the instance whose resources you want to delete.

    3. In the left-side navigation pane, choose Configuration management > Configuration list.

    4. On the Configuration list page, find the configuration that you want to delete and click Delete in the Actions column.

    5. In the Delete Configuration message, click OK.

  5. Delete applications.

    1. Log on to the ACK console.

    2. On the Clusters page, click the name of the cluster that you want to manage.

    3. In the left-side navigation pane, choose Workloads > Deployments.

    4. On the page that appears, select the applications that you want to delete and click Batch Delete.

    5. In the message that appears, click OK.

  6. Optional. Release an instance. For more information about refund policies, see Refund policy of Microservices Registry and Refund policy of cloud-native gateways.

What to do next