All Products
Search
Document Center

Alibaba Cloud Service Mesh:Configure a URI path matching rule

Last Updated:Dec 01, 2025

A service mesh proxy processes a request based on the requested URI and the HTTP rule configured in a virtual service. Virtual services support exact match, prefix match, and regular expression match of URI paths. This topic describes how to configure a URI path matching rule.

Prerequisites

The preparations are completed, and the helloworld and sleep services are deployed. For more information, see Preparations.

Procedure

  1. Check whether the service configurations take effect.

    1. In the kubeconfig environment for your ACK cluster, run the following command to start a bash session in the sleep environment:

      kubectl exec -it deploy/sleep -- sh
    2. Run the following command to send a request to the helloworld service:

      curl helloworld:5000/hello

      The expected output shows that either helloworld-v1 or helloworld-v2 responds at random. This indicates that requests are sent to the helloworld service.

      Hello version: v2, instance: helloworld-v2-7d48f6b995-6****
      Hello version: v1, instance: helloworld-v1-6986f64596-s****
  2. Use the following content to create a virtual service and add a URI path matching configuration. For more information, see Manage virtual services.

    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: helloworld-vs
      namespace: default
    spec:
      hosts:
        - helloworld
      http:
        - match:
            - uri:
                exact: /hello
          route:
            - destination:
                host: helloworld-v1
  3. Check whether the configurations take effect.

    1. In the kubeconfig environment for your ACK cluster, run the following command to start a bash session in the sleep environment:

      kubectl exec -it deploy/sleep -- sh
    2. Run the following command to send a request to the /hello path of the helloworld service.

      curl helloworld:5000/hello

      The expected output is always that helloworld-v1 responds to the request.

      Hello version: v1, instance: helloworld-v1-6986f64596-s****