All Products
Search
Document Center

Alibaba Cloud Service Mesh:Configure traffic routing for an ASM Gateway

Last Updated:Aug 24, 2026

Service Mesh (ASM) provides an intuitive graphical user interface (GUI) for gateways. You can create DestinationRules and VirtualServices directly in the console without writing YAML, which simplifies traffic management. This topic shows you how to use the GUI to create traffic policies and routing rules.

Prerequisites

Example

This topic uses the Reviews service as an example to describe how to graphically configure traffic policies, such as load balancing and connection pools. After a traffic policy is created, a YAML file for the corresponding DestinationRule is automatically generated. For example, you can graphically create routing rules for the Bookinfo service, such as /productpage and /login. This allows you to access the Bookinfo service by using paths such as /productpage.

Create a domain

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose ASM Gateways > Ingress Gateway.

  3. On the Ingress Gateway page, click the name of the target gateway. In the left-side navigation pane of the gateway details page, click Domain/Certificate.

  4. On the Add domain page, configure the following parameters and click Create.

    Parameter

    Example

    Domain

    *

    Protocol

    HTTP

    Namespaces

    default

    Port Name

    http

    Port

    80

    image

Import upstream services

Import services into the ASM Gateway to associate them with the gateway.

  1. On the Ingress Gateway page, click the name of the target gateway. In the left-side navigation pane of the gateway details page, click Upstream Service.

  2. On the Upstream Service page, click Import service. On the Import service page, select a Namespaces, select the reviews and productpage services, click the 上游服务 icon to add them to the list of selected services, and then click Confirm.

    导入服务

Create a traffic policy

  1. Define service versions.

    This step divides the reviews service into three versions (subsets): v1, v2, and v3.

    1. On the Upstream Service page, find the reviews service and click versions in the Operator column.

    2. On the versions page, click Add Service Version (Subset), set Name to v1, click Add Label, set the Key to version, and set the Value to v1.

    3. Click Add Service Version (Subset). Set Name to v2, click Add Label, set the Key to version, and set the Value to v2.

    4. Click Add Service Version (Subset). Set Name to v3, click Add Label, set the Key to version, set the Value to v3, and then click Create.

  2. Create the traffic policy.

    1. On the Upstream Service page, find the reviews service and click traffic policy in the Operator column.

    2. On the traffic policy page, click Add Policy, select Subset Level, and choose the v3 version. Enable Load Balancing, select Simple mode, set Mode to Random, and then click Submit.

      流量策略

  3. (Optional) View the DestinationRule YAML file generated after you create the traffic policy.

    On the Upstream Service page, find the reviews service and click View YAML in the Operator column. In the Preview dialog box, review the YAML file and click Confirm.

    Note

    Alternatively, on the mesh details page, choose Traffic Management Center > DestinationRule in the left-side navigation pane. On the DestinationRule page, find the target rule and click View YAML in the Operator column. In the Edit dialog box, you can view the YAML file of the generated DestinationRule.

    YAML file

    apiVersion: networking.istio.io/v1beta1
    kind: DestinationRule
    metadata:
      name: reviews
      namespace: default
      labels:
        provider: asm
    spec:
      host: reviews
      subsets:
        - name: v1
          labels:
            version: v1
        - name: v2
          labels:
            version: v2
        - name: v3
          labels:
            version: v3
          trafficPolicy:
            loadBalancer:
              simple: RANDOM

Create routing rules

  1. Create the routing rules for the Bookinfo application.

    1. Create the /productpage route.

      1. In the left-side navigation pane of the gateway details page, click Route management, and then click Create.

      2. In the set route detail wizard, configure the following parameters and click Next.

        Parameter

        Example

        route type

        Set to http.

        Namespaces

        Set to default.

        route name

        Set to productpage-route.

        description

        Set to productpage route.

        priority

        Set to 3.

        Note

        Routing rules are prioritized. A smaller number indicates a higher priority. If a request URI matches multiple routing rules, the rule with the highest priority is applied.

        Matching rules

        Specifies the URL matching criteria. Only requests with matching URLs are routed to the destination service.

        Enable Matching request URI. Set Method to Exact and Content to /productpage.

        Note

        You can also click Add Header Matching Rule to set header-based matching.

      3. In the set route destination wizard, configure the following parameters and click Next.

        Parameter

        Example

        select upstream service

        The destination service for this route. Select productpage.

        Port

        Optional. The port exposed by the upstream service. If the service exposes multiple ports, you must specify one. Leave this blank.

        Subset

        The destination service version (subset) for this route. Leave this blank.

        Weight

        The traffic weight for the destination service. Leave this blank.

      4. In the advanced config wizard, enable Fault Injection. Then, enable Request Latency, set Latency to 4s, and set Injection Percentage to 100. Click Create.

    2. Create the /static route.

      1. On the Route management page, click Create.

      2. In the set route detail wizard, configure the following parameters and click Next.

        Parameter

        Example

        route type

        Set to http.

        Namespaces

        Set to default.

        route name

        Set to static.

        description

        Set to static resource.

        priority

        Set to 0.

        Matching rules

        Specifies the URL matching criteria. Only requests with matching URLs are routed to the destination service.

        Enable Matching request URI. Set Method to Prefix and Content to /static.

      3. The subsequent steps for creating the /static route are the same as those for creating the /productpage route. For more information, see Create the /productpage route.

    3. Create the /login route.

      1. On the Route management page, click Create.

      2. In the set route detail wizard, configure the following parameters and click Next.

        Parameter

        Example

        route type

        Set to http

        Namespaces

        Set to default.

        route name

        Set to login.

        description

        Set to login request route.

        priority

        Set to 0.

        Matching rules

        Specifies the URL matching criteria. Only requests with matching URLs are routed to the destination service.

        Enable Matching request URI. Set Method to Prefix and Content to /login.

      3. The subsequent steps for creating the /login route are the same as those for creating the /productpage route. For more information, see Create the /productpage route.

    4. Create the /logout route.

      1. On the Route management page, click Create.

      2. In the set route detail wizard, configure the following parameters and click Next.

        Parameter

        Example

        route type

        Set to http.

        Namespaces

        Set to default.

        route name

        Set to logout.

        description

        Set to logout route.

        priority

        Set to 0.

        Matching rules

        Specifies the URL matching criteria. Only requests with matching URLs are routed to the destination service.

        Enable Matching request URI. Set Method to Prefix and Content to /logout.

      3. The subsequent steps for creating the /logout route are the same as those for creating the /productpage route. For more information, see Create the /productpage route.

    5. Create the /api/v1/products route.

      1. On the Route management page, click Create.

      2. In the set route detail wizard, configure the following parameters and click Next.

        Parameter

        Description

        route type

        Set to http.

        Namespaces

        Set to default.

        route name

        Set to products-route.

        description

        Set to product information.

        priority

        Set to 0.

        Matching rules

        Specifies the URL matching criteria. Only requests with matching URLs are routed to the destination service.

        Enable Matching request URI. Set Method to Prefix and Content to /api/v1/products.

      3. The subsequent steps for creating the /api/v1/products route are the same as those for creating the /productpage route. For more information, see Create the /productpage route.

  2. Verify that the routing rules are effective.

    1. In the address bar of your browser, enter http://{IP_address_of_ingress_gateway}/productpage.

      The following page appears.访问服务

    2. In the upper-right corner of the Bookinfo page, click Sign in.

    3. On the Please sign in page, enter any username and password, and click Sign in.

      You are logged in to the Bookinfo application.登录bookinfo

      You can also access the Bookinfo service by using the /logout, /static, and /api/v1/products paths to verify the routing rules.

    4. Open the developer tools of your browser and switch to the Network tab.

    5. Refresh the page.

      A delay of approximately 4 seconds is displayed, which indicates that the fault injection rule is in effect.延迟

  3. (Optional) View the YAML file of the VirtualService that is generated after the routing rules are created.

    1. On the details page of the ASM instance, choose Traffic Management Center > VirtualService in the left-side navigation pane.

    2. On the Virtual Service page, find the target VirtualService and click View YAML in the Operator column.

    3. In the Edit dialog box, view the YAML file of the generated VirtualService. After you confirm that the file is correct, click OK.

Related operations

View service details

View details about an imported service, such as whether a sidecar is injected and the region where the service is deployed.

  1. On the Ingress Gateway page, click the name of the target gateway. In the left-side navigation pane of the gateway details page, click Upstream Service.

  2. On the Upstream Service page, find the target service and click service details in the Operator column. On the service details page, you can view information such as whether a sidecar is injected and the region of the service.

Take a routing rule offline

Take a routing rule offline to make it inactive.

  1. On the Ingress Gateway page, click the name of the target gateway.

  2. In the left-side navigation pane of the gateway details page, click Route management.

  3. On the Route management page, find the target routing rule and click offline in the Operator column.

  4. In the Confirm dialog box, click OK.

  5. Verify that the routing rule is offline.

    1. In the address bar of your browser, enter http://{IP_address_of_ingress_gateway}/productpage.

    2. In the upper-right corner of the Bookinfo page, click Sign in.

    3. On the Please sign in page, enter any username and password, and click Sign in.

      路由下线

      A "page not found" error appears, which confirms that the routing rule is inactive.

      Note

      To reactivate a routing rule, bring it online:

      On the Route management page, find the target routing rule and click online in the Operator column. In the Confirm dialog box, click OK.