×
Community Blog Define Routing Rules for Applications in ASM

Define Routing Rules for Applications in ASM

This article describes how to define two types of Istio resources, namely virtual services and Istio gateways.

By Wang Xining

This is the last edition in the ASM Public Preview Series, a collection of articles that describes key capabilities of Alibaba Cloud Service Mesh (ASM). By managing Istio resource definitions, Alibaba Cloud ASM implements traffic management, authentication, and security protection. This article describes how to define two types of Istio resources: virtual services and Istio gateways. Find below the links to other articles in this series:

Define Virtual Services

  • In the Control Plane area, click the Virtual Service tab and then click Create.
  • On the Create page, define a virtual service, and click OK.
  • Select a namespace. In this example, the selected namespace is the default.
  • In the target field, define the Istio virtual service. Define the Istio virtual service by referring to the following YAML definition.
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
  • On the Virtual Service page, view the created Bookinfo service.

1

Define an Istio Gateway

  • In the Control Plane area, click the Service Gateway tab and then click Create.
  • On the Create page, define an Istio gateway, and click OK.
  • Select a namespace. In this example, the selected namespace is the default.
  • In the target field, define the Istio gateway. Define the Istio gateway by referring to the following YAML definition.
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
  • On the Service Gateway page, view the created Bookinfo gateway.

2

Results

In the address bar of the browser, enter http://{IP address of the ingress gateway service}/productpage and press Enter. The Bookinfo page appears. Complete the following steps to view the IP address of the ingress gateway service:

  • Log on to the Container Service console and choose Ingresses and Load Balancing > Service.
  • On the Service page, select the target cluster from the Cluster drop-down list and istio-system from the Namespace drop-down list for deploying the ingress gateway.
  • View external endpoint information about the istio-ingress gateway service, that is, the IP address of the ingress gateway service.
  • Also, log on to the kubectl client to check the IP address of the ingress gateway service. In the cluster environment where the ingress gateway is deployed, run the following command:
kubectl get service istio-ingressgateway -n istio-system -o jsonpath="{.status.loadBalancer.ingress[*].ip}"

3

The Reviews microservice has three versions. Therefore, the display content varies depending on the microservice version after refreshing the page.

  • Version 1 does not call the Ratings service.
  • Version 2 calls the Ratings service and displays rating information with one to five black stars.
  • Version 3 calls the Ratings service and displays rating information with one to five red stars.

Continue defining target rules or modifying virtual services to use other Istio features.

0 0 0
Share on

Xi Ning Wang(王夕宁)

23 posts | 6 followers

You may also like

Comments

Xi Ning Wang(王夕宁)

23 posts | 6 followers

Related Products