For applications that run on virtual machines, you can use Istio Proxy to connect the data plane in which the applications reside to the control plane of an Alibaba Cloud Service Mesh (ASM) instance. After you start Istio Proxy, you can use the ASM instance to manage applications that run on the virtual machines. This topic shows you how to use ASM to manage a Bookinfo application that runs on virtual machines.

Prerequisites

Background information

After you start Istio Proxy, you can add a Bookinfo application that runs on the virtual machines to the ASM instance. This way, you can use the ASM instance to call the Bookinfo application. Call procedure

Prepare an environment for the virtual machines

Before you deploy the Bookinfo application on the virtual machines, you must prepare an environment for the virtual machines. The following table describes the environment requirements for the virtual machines. In this topic, the Bookinfo application is used as an example. You can prepare an environment for the virtual machines based on your needs.
Virtual machine Distribution Kernel version Microservice in a Bookinfo application
vm1 Ubuntu 20.04.1 LTS 5.4.0-65-generic productpage
vm2 Ubuntu 20.04.1 LTS 5.4.0-65-generic reviews-v1
vm3 CentOS Linux release 8.3.2011 4.18.0-240.15.1.el8_3.x86_64 reviews-v2
vm4 CentOS Linux release 8.3.2011 4.18.0-240.15.1.el8_3.x86_64 reviews-v3
vm5 Alibaba Cloud Linux (Aliyun Linux) release 2.1903 LTS 4.19.91-23.al7.x86_64 details
vm6 Alibaba Cloud Linux (Aliyun Linux) release 2.1903 LTS 4.19.91-23.al7.x86_64 ratings

Step 1: Obtain the private IP addresses of the virtual machines

  1. Log on to the ASM console.
  2. In the left-side navigation pane, choose Service Mesh > Mesh Management.
  3. On the Mesh Management page, find the ASM instance that you want to configure. Click the name of the ASM instance or click Manage in the Actions column of the ASM instance.
  4. On the details page of the ASM instance, choose Data Plane (Service Discovery) > VMs in the left-side navigation pane.
    On the VMs page, find the virtual machines on which you want to deploy the Bookinfo application and view their IP addresses in the IP column.

Step 2: Deploy the Bookinfo application on the virtual machines

  1. Run the following commands to deploy the productpage microservice:
    PRODUCTPAGE_REPO=docker.io/istio/examples-bookinfo-productpage-v1:1.16.2
    
    docker run -d \
        --name=productpage \
        -e SERVICES_DOMAIN=bookinfo \
        --network=host \
        $PRODUCTPAGE_REPO
  2. Run the following commands to deploy the reviews-v1 microservice:
    REVIEWS_REPO=docker.io/istio/examples-bookinfo-reviews-v1:1.16.2
    docker run -d \
        --name=reviews1 \
        -e SERVICES_DOMAIN=bookinfo \
        --network=host \
        $REVIEWS_REPO
  3. Run the following commands to deploy the reviews-v2 microservice:
    REVIEWS_REPO=docker.io/istio/examples-bookinfo-reviews-v2:1.16.2
    docker run -d \
        --name=reviews2 \
        -e SERVICES_DOMAIN=bookinfo \
        --network=host \
        $REVIEWS_REPO
  4. Run the following commands to deploy the reviews-v3 microservice:
    REVIEWS_REPO=docker.io/istio/examples-bookinfo-reviews-v3:1.16.2
    docker run -d \
        --name=reviews3 \
        -e SERVICES_DOMAIN=bookinfo \
        --network=host \
        $REVIEWS_REPO
  5. Run the following commands to deploy the details microservice:
    DETAILS_REPO=docker.io/istio/examples-bookinfo-details-v1:1.16.2
    docker run -d \
        --name=details \
        --network=host \
        $DETAILS_REPO
  6. Run the following commands to deploy the ratings microservice:
    RATINGS_REPO=docker.io/istio/examples-bookinfo-ratings-v1:1.16.2
    docker run -d \
        --name=ratings \
        --network=host \
        $RATINGS_REPO

Step 3: Configure a routing rule for the Bookinfo application in the ASM instance

  1. Configure the productpage microservice in the ASM instance.
    1. Log on to the ASM console.
    2. In the left-side navigation pane, choose Service Mesh > Mesh Management.
    3. On the Mesh Management page, find the ASM instance that you want to configure. Click the name of the ASM instance or click Manage in the Actions column of the ASM instance.
    4. On the details page of the ASM instance, choose Traffic Management > ServiceEntry in the left-side navigation pane. On the Service entry page, click Create from YAML.
    5. On the Create page, select a namespace, copy the following content to the code editor, and then click Create.
      The created service entry adds the productpage microservice to the internal service registry of the ASM instance.
      apiVersion: networking.istio.io/v1beta1
      kind: ServiceEntry
      metadata:
        name: mesh-expansion-productpage
        namespace: bookinfo
      spec:
        hosts:
          - productpage.bookinfo.svc.cluster.local
          - productpage.bookinfo
        location: MESH_INTERNAL
        ports:
          - name: http-9080
            number: 9080
            protocol: HTTP
        resolution: STATIC
        workloadSelector:
          labels:
            app: productpage
    6. On the details page of the ASM instance, choose Traffic Management > WorkloadEntry in the left-side navigation pane. On the Workload entry page, click Create from YAML.
    7. On the Create page, select a namespace, copy the following content to the code editor, and then click Create.
      The created workload entry defines the workload properties of the productpage microservice.
      apiVersion: networking.istio.io/v1beta1
      kind: WorkloadEntry
      metadata:
        name: mesh-expansion-productpage-1
        namespace: bookinfo
      spec:
        address: 10.0.*.**
        labels:
          app: productpage
        serviceAccount: bookinfo-productpage

      address: the private IP address of the virtual machine. Set the value to the IP address of the virtual machine on which the productpage microservice is deployed. For more information about how to obtain the IP address of the virtual machine on which the productpage microservice is deployed, see Step 1: Obtain the private IP addresses of the virtual machines.

  2. Configure the reviews microservice in the ASM instance.
    1. Use the following content to create a service entry. For more information, see Step 1.
      The created service entry adds the reviews microservice to the internal service registry of the ASM instance.
      apiVersion: networking.istio.io/v1beta1
      kind: ServiceEntry
      metadata:
        name: mesh-expansion-reviews
        namespace: bookinfo
      spec:
        hosts:
          - reviews.bookinfo.svc.cluster.local
          - reviews.bookinfo
        location: MESH_INTERNAL
        ports:
          - name: http-9080
            number: 9080
            protocol: HTTP
        resolution: STATIC
        workloadSelector:
          labels:
            app: reviews
                                      
    2. Use the following content to create a workload entry. For more information, see Step 1.
      The created workload entry defines the workload properties of the reviews microservice.
      apiVersion: networking.istio.io/v1beta1
      kind: WorkloadEntry
      metadata:
        name: mesh-expansion-reviews-1
        namespace: bookinfo
      spec:
        address: 10.0.**.**
        labels:
          app: reviews
        serviceAccount: bookinfo-reviews
      ---
      apiVersion: networking.istio.io/v1beta1
      kind: WorkloadEntry
      metadata:
        name: mesh-expansion-reviews-2
        namespace: bookinfo
      spec:
        address: 10.0.**.**
        labels:
          app: reviews
        serviceAccount: bookinfo-reviews
      ---
      apiVersion: networking.istio.io/v1beta1
      kind: WorkloadEntry
      metadata:
        name: mesh-expansion-reviews-3
        namespace: bookinfo
      spec:
        address: 10.0.**.**
        labels:
          app: reviews
        serviceAccount: bookinfo-reviews

      address: the private IP address of the virtual machine. Set the values to the IP address of the virtual machine on which the reviews-v1 microservice is deployed, the IP address of the virtual machine on which the reviews-v2 microservice is deployed, and the IP address of the virtual machine on which the reviews-v3 microservice is deployed. For more information about how to obtain the IP addresses of the virtual machines on which the reviews microservice is deployed, see Step 1: Obtain the private IP addresses of the virtual machines.

  3. Configure the details microservice in the ASM instance.
    1. Use the following content to create a service entry. For more information, see Step 1.
      The created service entry adds the details microservice to the internal service registry of the ASM instance.
      apiVersion: networking.istio.io/v1beta1
      kind: ServiceEntry
      metadata:
        name: mesh-expansion-details
        namespace: bookinfo
      spec:
        hosts:
          - details.bookinfo.svc.cluster.local
          - details.bookinfo
        location: MESH_INTERNAL
        ports:
          - name: http-9080
            number: 9080
            protocol: HTTP
        resolution: STATIC
        workloadSelector:
          labels:
            app: details
    2. Use the following content to create a workload entry. For more information, see Step 1.
      The created workload entry defines the workload properties of the details microservice.
      apiVersion: networking.istio.io/v1beta1
      kind: WorkloadEntry
      metadata:
        name: mesh-expansion-details-1
        namespace: bookinfo
      spec:
        address: 10.0.**.**
        labels:
          app: details
        serviceAccount: bookinfo-details

      address: the private IP address of the virtual machine. Set the value to the IP address of the virtual machine on which the details microservice is deployed. For more information about how to obtain the IP address of the virtual machine on which the details microservice is deployed, see Step 1: Obtain the private IP addresses of the virtual machines.

  4. Configure the ratings microservice in the ASM instance.
    1. Use the following content to create a service entry. For more information, see Step 1.
      The created service entry adds the ratings microservice to the internal service registry of the ASM instance.
      apiVersion: networking.istio.io/v1beta1
      kind: ServiceEntry
      metadata:
        name: mesh-expansion-ratings
        namespace: bookinfo
      spec:
        hosts:
          - ratings.bookinfo.svc.cluster.local
          - ratings.bookinfo
        location: MESH_INTERNAL
        ports:
          - name: http-9080
            number: 9080
            protocol: HTTP
        resolution: STATIC
        workloadSelector:
          labels:
            app: ratings
    2. Use the following content to create a workload entry. For more information, see Step 1.
      The created workload entry defines the workload properties of the ratings microservice.
      apiVersion: networking.istio.io/v1beta1
      kind: WorkloadEntry
      metadata:
        name: mesh-expansion-ratings-1
        namespace: bookinfo
      spec:
        address: 10.0.**.**
        labels:
          app: ratings
        serviceAccount: bookinfo-ratings

      address: the private IP address of the virtual machine. Set the value to the IP address of the virtual machine on which the ratings microservice is deployed. For more information about how to obtain the IP address of the virtual machine on which the ratings microservice is deployed, see Step 1: Obtain the private IP addresses of the virtual machines.

  5. Configure an Istio gateway for the Bookinfo application.
    1. On the details page of the ASM instance, choose Traffic Management > Gateway in the left-side navigation pane. On the Gateway rules page, click Create from YAML.
    2. On the Create page, select a namespace, copy the following content to the code editor, and then click Create.
      apiVersion: networking.istio.io/v1alpha3
      kind: Gateway
      metadata:
        name: bookinfo-gateway
      spec:
        selector:
          istio: ingressgateway
        servers:
        - port:
            number: 80
            name: http
            protocol: HTTP
          hosts:
          - "*"
  6. Configure a routing rule for the Bookinfo application.
    1. On the details page of the ASM instance, choose Traffic Management > VirtualService in the left-side navigation pane. On the Virtual service page, click Create from YAML.
    2. On the Create page, select a namespace, copy the following content to the code editor, and then click Create.
      The created virtual service allows requests that contain productpage, static, login, logout, or api/v1/products to access the productpage microservice.
      apiVersion: networking.istio.io/v1alpha3
      kind: VirtualService
      metadata:
        name: bookinfo
      spec:
        hosts:
        - "*"
        gateways:
        - bookinfo-gateway
        http:
        - match:
          - uri:
              exact: /productpage
          - uri:
              prefix: /static
          - uri:
              exact: /login
          - uri:
              exact: /logout
          - uri:
              prefix: /api/v1/products
          route:
          - destination:
              host: productpage
              port:
                number: 9080
  7. View the IP address of the ingress gateway service.
    1. Log on to the ASM console.
    2. In the left-side navigation pane, choose Service Mesh > Mesh Management.
    3. On the Mesh Management page, find the ASM instance that you want to configure. Click the name of the ASM instance or click Manage in the Actions column of the ASM instance.
    4. On the details page of the ASM instance, click ASM Gateways in the left-side navigation pane. On the ASM Gateways page, view the IP address of the ingress gateway service in the Port Mapping column.

Verify the result

Enter <IP address of the ingress gateway service>/productpage in the address bar of a browser. If the following page appears, ASM can manage the Bookinfo application that runs on the virtual machines. Bookinfo page