This topic describes how to use Alibaba Cloud Container Service to deploy and run a Bookinfo sample.

Prerequisites

Bookinfo application overview

Bookinfo is a sample application composed of four separate microservices that are used to demonstrate various Istio features.

  • productpage: The productpage microservice calls the details and reviews microservices to populate the page.
  • details: This microservice contains the book information.
  • reviews: This microservice contains the book reviews. It also calls the ratings microservice.
  • ratings: The ratings microservice contains book ranking information that accompanies a book review.

The reviews microservice has three versions:

  • Version v1 does not call the ratings service.
  • Version v2 calls the ratings service and displays each rating as 1 to 5 black stars.
  • Version v3 calls the ratings service and displays each rating as 1 to 5 red stars.
The end-to-end architecture of the application is shown as follows.

Deploy the Bookinfo application

In this example, you have deployed Istio, created a namespace named istio-test, and enabled the automatic sidecar injection function.

You can see a new label istio-injection:enabled in the istio-test namespace.

You can use the console to deploy productpage, details, rating, and the two versions of the reviews microservice (version v1 and version v2).

This example describes how to deploy the productpage microservice.

  1. Log on to the Container Service console.
  2. In the Kubernetes menu, choose Service Mesh > Virtual Services in the left-side navigation pane, and then click Create in the upper-right corner of the page.
  3. Specify Name, Version, Clusters, Namespaces and Replicas. The Replicas parameter specifies the number of Pods included in the application. Click Next.
    This example uses the istio-test namespace.
  4. Configure the container.
    Configure the image name, image version, required resources, port, and other information.
    Note
    In this example, the parameter values are as follows:
    • Image Name: You can click Select Image. In the dialog box that appears, select an image and click OK. You can also enter a private registry to specify the image. In this example, the registry is docker.io/istio/example-bookinfo-productpage-v1.
    • Image Version: You can click Select Image Version to select the image version. If you do not specify the image version, the latest version is used. In this example, the image version is 1.15.0.
    • Required Resources: The number of cores and memory that are reserved for this application. These resources are exclusive to the container. This prevents the application from being unavailable when other services or processes compete for resources. In this example, the CPU is 0.25-core and the memory is 256 MiB.
    • Port: You need to add the host port and the container port. TCP and UDP protocols are supported. In this example, the container port is 9080 and the protocol is TCP.
    For more information about other parameters, see Create deployments by using images.
  5. Set the parameters based on your business requirements and then click Next.
  6. Configure the service.
    1. In the Service (Service) column, click Create and configure the service in the dialog box that appears.
      • Name: You can specify the name as needed. The default name is applicationname-svc.
      • Type: Select one from the following three types.
        • Cluster IP: Expose the service through an internal IP address of the cluster. If you select this option, the service is only accessible within the cluster.
        • Node Port: Expose the service through the IP address and static port (NodePort) on each node. A Node Port service can route requests to a Cluster IP service, which is automatically created by the system. You can access a Node Port service from outside the cluster by requesting <NodeIP>:<NodePort>.
        • Server Load Balancer: Expose the service through Server Load Balancer (SLB), which supports Internet access and internal access. An SLB service can route requests to Node Port and Cluster IP services.
      • Port Mapping: Add the service port and container port. TCP and UDP protocols are supported.
      • Annotations: Add an annotation to the service. SLB parameters are supported. For more information, see Access services by using SLB.
      • Label: Add a label to the service.
    2. Click Create.

You can follow the preceding procedure to create the details, ratings, and reviews (v1) services.

After these services are created, wait until all services and pods are started properly.

Create a service gateway

  1. In the left-side navigation pane under Container Service - Kubernetes, choose Service Mesh > Gateways. The Gateways page appears on the right.
  2. Select the cluster and namespace, and click Create in the upper-right corner.
  3. Set the gateway parameters and click Create. The gateway is deployed.
    • Name: the name of the gateway to deploy.
    • Service: the gateway proxy. The default proxy is istio-ingressgateway. The proxy must be in the same namespace as the gateway to deploy.
    • Ports: the gateway port. You can click Add to configure multiple ports for the gateway.
      • Name: the port name.
      • Protocol: the gateway protocol. Valid values: HTTP and TCP.
      • Port: the port number. Valid values: 1 to 65535.
      • Host: the gateway host. You can add multiple hosts for the gateway.
    You can find the newly created gateway on the Gateways page.
  4. Bind the preceding services to the Bookinfo-gateway. For more information, see Bind a virtual service to a gateway.
    1. In the left-side navigation pane under Container Service - Kubernetes, choose Service Mesh > Virtual Services. The Virtual Services page appears.
      Note In the Gateways column, the Bind button is available for virtual services that are not bound to gateways.
    2. In the Gateways column, click Bind for the target virtual service. The Add page appears.
    3. Select a gateway from the Name drop-down list and click OK. The virtual service is bound to the gateway.
  5. On the Gateways page, click istio-ingressgateway of the target gateway, and enter IP address/productpage.
    The following page is displayed.

Deploy the v2 version of the reviews microservice

  1. In the left-side navigation pane under Container Service - Kubernetes, choose Service Mesh > Virtual Services. The Virtual Services page appears.
  2. In the Actions column of the target gateway, click Manage to go to the details page.
  3. Click Add New Canary Version.
  4. Go to the Create Application page. You can configure the parameters as needed.
    1. On the Basic Information page, specify Version and Replicas, and then click Next.
    2. On the Container page, set the image name, image version, required resources, container port, and other configuration information, and then click Next.
      Note
      In this example, the parameter values are as follows:
      • Image Name: Click Select Image. In the dialog box that appears, select an image, and then click OK. You can also enter a private registry to specify the image. In this example, Docker. io/istio/example-bookinfo-productpage-v2. is used.
      • Image Version: Click Select Image Version, and then select the image version. If you do not specify the image version, the latest version is used. In this example, 1.15.0 is used.
      • Required Resources: The amount of CPU and memory resources that are reserved for this application. These resources are exclusive to the container. This prevents the application from being unavailable when other services or processes compete for resources. In this example, the CPU is 0.25-core and the memory is 256 MiB.
      • Port: You need to add the host port and the container port. The TCP and UDP protocols are supported. In this example, the container port is 9080 and the protocol is TCP.
      For more information about other parameters, see Create deployments by using images.
    3. On the Canary Release page, select Weight based Routing. In the Traffic Weight column, set the traffic weight to 50%, and then click Create.
  5. After the Pod is started, enter IP address/productpage. The page of the v2 version appears.
    The traffic ratio of v1 and v2 is 50% each. You may need to refresh the page several times.bookinfo-sample

Result

You can use stress testing tools, such as siege, to simulate multiple visits, and then observe the traffic topology by using Kiali.
Kiali is installed by default when Istio is deployed. You only need to create an Ingress to access Istio. For more information, see Create an Ingress on the web UI.
Note In this example, the cluster where Istio has been deployed is selected as the target cluster and the isti-system namespace is selected.

After the creation is complete, you can see the URL of Kiali in the IP address list.

Click the URL of Kiali to log on to the Kiali console. You can see the following results.
Note By default, the username and password are set to admin.