You can create destination rules and virtual services for a Service Mesh (ASM) gateway on a graphical user interface (GUI) without writing YAML files. This simplifies traffic management. This topic describes how to create traffic policies and routing rules for an ASM gateway on a GUI.
Prerequisites
The cluster is added to the ASM instance. For more information, see Add a cluster to an ASM instance.
An ingress gateway is deployed. For more information, see Create an ingress gateway.
An application is deployed in the ASM instance. For more information, see Deploy an application in an ASM instance.
Automatic sidecar proxy injection is enabled for the specified namespaces. For more information, see Enable automatic sidecar proxy injection.
The IP address of the specified ASM gateway is obtained. For more information, see substep 1 of Step 3 in the Use Istio resources to route traffic to different versions of a service topic.
Background information
You can create a traffic policy that specifies the load balancing and connection pool settings for a service on a GUI. In this example, the reviews service is used. After the traffic policy is created, a YAML file for a destination rule is automatically generated. You can create routing rules for a service to match specific content in a URL, such as /productpage and /login. In this example, the Bookinfo service is used. This way, you can access the Bookinfo service by using a URL that contains information such as /productpage.
Create a traffic policy
Import an upstream service.
Import the reviews service to the ASM gateway to associate the ASM gateway with the reviews service.
Log on to the ASM console. In the left-side navigation pane, choose .
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
On the Ingress Gateway page, click the name of the ASM gateway to which you want to import the reviews service.
In the left-side navigation pane of the Gateway overview page, click Upstream Service.
On the Gateway upstream services page, click Import service.
On the Import service page, select a namespace from the Namespace drop-down list. In the select service box, select the reviews service and click the icon to move the reviews service to the selected box. Then, click Submit.
Manage versions of the reviews service.
Group instances of the reviews service by version. In this example, the versions of the reviews service are v1, v2, and v3.
On the Gateway upstream services page, find the reviews service and click versions in the Actions column.
On the versions page, click Add Service Version (Subset). Set the Name parameter to v1. Then, click Add Label and set the Key parameter to version and the Value parameter to v1.
Click Add Service Version (Subset) again. Set the Name parameter to v2. Then, click Add Label and set the Key parameter to version and the Value parameter to v2.
Click Add Service Version (Subset) again. Set the Name parameter to v3. Then, click Add Label and set the Key parameter to version and the Value parameter to v3. Then, click Create.
Create a traffic policy.
On the Gateway upstream services page, find the reviews service and click traffic policy in the Actions column.
On the Traffic Policy page, click Add Policy. Select Subset Level and select v3 from the Subset drop-down list. Turn on Load Balancing and select Simple. Then, set the Mode parameter to Random and click Submit.
(Optional) After the traffic policy is created, view the YAML file that is automatically generated for a destination rule.
On the Gateway upstream services page, find the reviews service and click YAML in the Actions column to view the YAML file in the Preview dialog box. After you confirm the correctness of the YAML file, click Submit.
NoteYou can also choose
in the left-side navigation pane on the details page of the ASM instance. On the DestinationRule page, find the rule whose YAML file you want to view and click YAML in the Actions column. In the Edit dialog box, view the YAML file of the destination rule.
Create routing rules
Import an upstream service.
Import the productpage service to the ASM gateway to associate the ASM gateway with the productpage service.
Log on to the ASM console. In the left-side navigation pane, choose .
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
On the Ingress Gateway page, click the name of the ASM gateway to which you want to import the productpage service.
In the left-side navigation pane of the Gateway overview page, click Upstream Service.
On the Gateway upstream services page, click Import service.
On the Import service page, select a namespace from the Namespace drop-down list. In the select service box, select the productpage service and click the icon to move the productpage service to the selected box. Then, click Submit.
Create routing rules.
Create a routing rule to match a URL that contains /productpage.
In the left-side navigation pane of the Gateway overview page, click Route management. On the page that appears, click Create.
In the set route detail step, set the parameters that are described in the following table, and then click Next.
Parameter
Description
route type
The type of the traffic to be routed. In this example, the value is http.
Namespace
The namespace in which you create the routing rule. In this example, the value is default.
Name
The name of the routing rule. In this example, the value is productpage-route.
description
The description of the routing rule. In this example, the value is productpage routing.
priority
The priority of the routing rule. A smaller value indicates a higher priority. If a URL matches multiple routing rules, the routing rule that has the highest priority takes precedence. In this example, the value is 3.
Matching Rule
The content to be matched in a URL. Only requests with a URL that contains the specified content can be routed to the destination service.
Turn on Matching request URI, set Method to Exact and Content to /productpage.
NoteYou can also click Add Header Matching Rule to configure settings for matching HTTP headers.
In the set route destination step, set the parameters that are described in the following table, and then click Next.
Parameter
Description
select upstream service
The service to which the routing rule applies. In this example, the value is productpage.
Port
(Optional) The port through which the routing rule connects to the upstream service. The upstream service may expose multiple ports. In this case, specify a port.
Subset
The version of the service to which the routing rule applies.
Weight
The traffic weight of the destination service.
In the advanced config step, turn on Fault Injection. After that, turn on Request Latency, set the Latency parameter to 4s and the Injection Percentage parameter to 100, and then click Create.
Create a routing rule to match a URL that contains /static.
On the Route management page, click Create.
In the set route detail step, set the parameters that are described in the following table, and then click Next.
Parameter
Description
route type
The type of the traffic to be routed. In this example, the value is http.
Namespace
The namespace in which you create the routing rule. In this example, the value is default.
Name
The name of the routing rule. In this example, the value is static.
description
The description of the routing rule. In this example, the value is static resource.
priority
The priority of the routing rule. A smaller value indicates a higher priority. If a URL matches multiple routing rules, the routing rule that has the highest priority takes precedence. In this example, the value is 0.
Matching Rule
The content to be matched in a URL. Only requests with a URL that contains the specified content can be routed to the destination service.
Turn on Matching request URI, set Method to Prefix and Content to /static.
The subsequent steps for creating a routing rule to match a URL that contains /static are the same as those for creating a routing rule to match a URL that contains /productpage. For more information, see the Create a routing rule to match a URL that contains /productpage section in this topic.
Create a routing rule to match a URL that contains /login.
On the Route management page, click Create.
In the set route detail step, set the parameters that are described in the following table, and then click Next.
Parameter
Description
route type
The type of the traffic to be routed. In this example, the value is http.
Namespace
The namespace in which you create the routing rule. In this example, the value is default.
Name
The name of the routing rule. In this example, the value is login.
description
The description of the routing rule. In this example, the value is login request routing.
priority
The priority of the routing rule. A smaller value indicates a higher priority. If a URL matches multiple routing rules, the routing rule that has the highest priority takes precedence. In this example, the value is 0.
Matching Rule
The content to be matched in a URL. Only requests with a URL that contains the specified content can be routed to the destination service.
Turn on Matching request URI and set the Method parameter to Prefix and the Content parameter to /login.
The subsequent steps for creating a routing rule to match a URL that contains /login are the same as those for creating a routing rule to match a URL that contains /productpage. For more information, see the Create a routing rule to match a URL that contains /productpage section in this topic.
Create a routing rule to match a URL that contains /logout.
On the Route management page, click Create.
In the set route detail step, set the parameters that are described in the following table, and then click Next.
Parameter
Description
route type
The type of the traffic to be routed. In this example, the value is http.
Namespace
The namespace in which you create the routing rule. In this example, the value is default.
Name
The name of the routing rule. In this example, the value is logout.
description
The description of the routing rule. In this example, the value is logout route.
priority
The priority of the routing rule. A smaller value indicates a higher priority. If a URL matches multiple routing rules, the routing rule that has the highest priority takes precedence. In this example, the value is 0.
Matching Rule
The content to be matched in a URL. Only requests with a URL that contains the specified content can be routed to the destination service.
Turn on Matching request URI and set the Method parameter to Prefix and the Content parameter to /logout.
The subsequent steps for creating a routing rule to match a URL that contains /logout are the same as those for creating a routing rule to match a URL that contains /productpage. For more information, see the Create a routing rule to match a URL that contains /productpage section in this topic.
Create a routing rule to match a URL that contains /api/v1/products.
On the Route management page, click Create.
In the set route detail step, set the parameters that are described in the following table, and then click Next.
Parameter
Description
route type
The type of the traffic to be routed. In this example, the value is http.
Namespace
The namespace in which you create the routing rule. In this example, the value is default.
Name
The name of the routing rule. In this example, the value is products-route.
description
The description of the routing rule. In this example, the value is product information.
priority
The priority of the routing rule. A smaller value indicates a higher priority. If a URL matches multiple routing rules, the routing rule that has the highest priority takes precedence. In this example, the value is 0.
Matching Rule
The content to be matched in a URL. Only requests with a URL that contains the specified content can be routed to the destination service.
Turn on Matching request URI, set Method to Prefix and Content to /api/v1/products.
The subsequent steps for creating a routing rule to match a URL that contains /api/v1/products are the same as those for creating a routing rule to match a URL that contains /productpage. For more information, see the Create a routing rule to match a URL that contains /productpage section in this topic.
Check whether the routing rules take effect.
In the address bar of Google Chrome, enter http://{IP address of the ASM gateway}/productpage.
The following figure shows an example on the page that appears.
In the upper-right corner of the Bookinfo page, click Sign in.
On the Please sign in page, enter your account and password and click Sign in.
The following figure shows the page of the Bookinfo service after logon.
You can also use a URL that contains /logout, /static, or /api/v1/products to access the Bookinfo service for verification.
In the upper-right corner of Google Chrome, click the icon and choose .
Refresh the page whose address is http://{IP address of the ASM gateway}/productpage.
On the Network tab, a delay of about 4 seconds is reported.
(Optional) After the routing rules are created, view the YAML files that are automatically generated for the corresponding virtual services.
On the details page of the ASM instance, choose in the left-side navigation pane.
On the VirtualService page, find the virtual service that you want to manage and click YAML in the Actions column.
In the Edit dialog box, view the YAML file of the virtual service. Confirm the settings and click OK.
Related operations
View service details
View the details of an imported service, such as the settings of the sidecar proxy injection and the region.
Log on to the ASM console. In the left-side navigation pane, choose .
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
On the Ingress Gateway page, click the name of the ASM gateway for which you want to view service details.
In the left-side navigation pane of the Gateway overview page, click Upstream Service.
On the Gateway upstream services page, find the service whose details you want to view and click service details in the Actions column.
On the service details page, view the details of the service, such as the settings of the sidecar proxy injection and the region.
Disable a routing rule
You can disable a routing rule so that this routing rule no longer takes effect.
Log on to the ASM console. In the left-side navigation pane, choose .
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
On the Ingress Gateway page, click the name of the ASM gateway for which you want to disable a routing rule.
In the left-side navigation pane of the Gateway overview page, click Route management.
On the page that appears, find the desired routing rule and click offline in the Actions column.
In the Submit message, click OK.
Verify that the disabled routing rule no longer takes effect.
In the address bar of Google Chrome, enter http://{IP address of the ASM gateway}/productpage.
In the upper-right corner of the Bookinfo page, click Sign in.
On the Please sign in page, enter your account and password and click Sign in.
A 404 error occurs, which indicates that the login routing rule is disabled and no longer takes effect.
You can enable a disabled routing rule by performing the following steps:
On the Route management page, find the routing rule that you want to enable and click online in the Actions column. In the Submit message, click OK.