All Products
Search
Document Center

Microservices Engine:Manage service versions

Last Updated:Apr 22, 2024

Service versions are used for the tag-based routing feature that is configured for routes of a cloud-native gateway. You can configure tag-based routing policies for routes to meet requirements in scenarios such as canary releases, tag-based routing, and high-availability deployments.

Note

You cannot manage the versions of services whose Service Source is set to Fixed Address or DNS Domain Name.

Background information

In microservices, services are defined as functional units of an application. Services are specific to fields such as order service and user service. Physically, services are deployed and run on physical machines, virtual machines, or inside containers with network addresses. Logically, a service consists of nodes that provide the same features.

Nodes of a service can be divided into different subsets based on the metadata on the nodes. A service version is referred to as a subset of nodes. Service versions are typically used in canary releases, tag-based routing, and high-availability deployments.

  • Canary releases: New versions of a service are frequently released across service iterations. To ensure service stability and continuity, developers use the canary release feature to perform service updates in most cases. If you perform a canary release to test the new version, a small percentage of traffic is routed to the new version. If the test result meets your expectation, the remaining traffic is gradually routed to the new version.

  • Tag-based routing: In business scenarios, multiple versions of a service may exist in parallel. Features of versions are different and applied to information-specific requests. For example, when the same API operation is called, requests with different header values are forwarded to different versions of the service. Tag-based routing is also used in the scenario where multiple development environments such as test, staging, and production environments coexist. You can use service versions to forward requests to different development environments based on the request information.

  • High-availability deployments: To ensure service availability, identical services may be deployed on multiple Kubernetes clusters. You can manage all service instances by cluster based on the cluster metadata on the nodes. You can also adjust the weightage to distribute traffic to clusters. If a cluster fails, you can set the traffic weight to 0 for the cluster, and all traffic is then forwarded to other clusters.

Service version management depends on the metadata on service nodes.

  • For services on Container Service for Kubernetes (ACK) clusters, the metadata on service nodes is determined by the Labels attributes of pods. For example, if you register a Spring Cloud service with an instance in the ACK cluster, you can add the tag name and tag value that correspond to the Spring Cloud service to spec.template.metadata.labels in the deployment.yaml file of the ACK cluster.

  • For services that use the Nacos registry, the metadata on service nodes is configured when the service application is registered in the registry. For example, if you register a Spring Cloud application with a Nacos instance, you can specify the spring.cloud.nacos.discovery.metadata field to determine the metadata on nodes.

Add a service version

  1. Log on to the MSE console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.

  3. In the left-side navigation pane, click Routes. On the page that appears, click the Services tab.

  4. Click the name of the service you want to change on the Services tab. In the Service Version section, click Add Version.

  5. In the service version list, configure the parameters and click the 完成 icon in the Actions column.

    服务版本列表

    Parameter

    Description

    Version Name

    Specify a name for the service version. We recommend that you use a short and descriptive name.

    Tag Name

    Select a tag name from the drop-down list. Tag names are used to identify a full set of keys that indicate the metadata on all nodes of a service. You must select a key to distinguish a set of service nodes for the service version that you want to add.

    Tag Value

    Select a tag value from the drop-down list. Tag values are used to identify a full set of values that correspond to the keys specified by Tag Name. You must select a value to further narrow down the scope of service nodes for the service version that you want to add.

    Number of Instances/Proportion

    • Number of Instances: the number of service nodes that are identified by the specified tag name and tag value. These nodes belong to the service version that you want to add.

    • Proportion: the proportion of service nodes that belong to the new service version to all service nodes.

    Note

    Tag Name and Tag Value are used together to identify instances of the service version that you want to add.

  6. In the message that appears, click OK.

    The added service version is displayed in the Service Version section.

Edit a service version

  1. Log on to the MSE console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.

  3. In the left-side navigation pane, click Routes. On the page that appears, click the Services tab.

  4. Click the name of the service that you want to change on the Services tab. In the Service Version section, find the desired version and click the 编辑 icon in the Actions column.

  5. Modify the settings of Tag Name and Tag Value, and click the 完成 icon in the Actions column.

  6. In the message that appears, click OK.

Delete a service version

  1. Log on to the MSE console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.

  3. In the left-side navigation pane, click Routes. On the page that appears, click the Services tab.

  4. Click the name of the service that you want to change on the Services tab. In the Service Version list, find the desired version and click the 删除 icon in the Actions column.

  5. In the message that appears, click OK.