Deploy Example Bookinfo Application

- By: Thomas Jungbauer ( Lastmod: 2021-08-14 ) - 2 min read

To test a second application, a bookinfo application shall be deployed as an example.

The following section finds it’s origin at:

The Bookinfo application displays information about a book, similar to a single catalog entry of an online book store.
Displayed on the page is a description of the book, book details (ISBN, number of pages, and other information), and book reviews.

The Bookinfo application consists of these microservices:

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

There are three versions of the reviews microservice:

* Version v1 does not call the ratings Service.
* Version v2 calls the ratings Service and displays each rating as one to five black stars.
* Version v3 calls the ratings Service and displays each rating as one to five red stars.

The end-to-end architecture of the application is shown below.
bookinfo
Figure 1. Bookinfo Application End2End Overview

To use the bookinfo application inside service mesh, no code changes are required. Instead an Envoy proxy is added as a sidecar container to all containers (product, review, details) which intercepts the traffic.


Installation

Let’s start right away:

  1. Create a new project

    oc new-project bookinfo
  2. Add the new project to our Service Mesh

    apiVersion: maistra.io/v1
    kind: ServiceMeshMember
    metadata:
      name: default
      namespace: bookinfo
    spec:
      controlPlaneRef:
        name: basic-install
        namespace: istio-system
  3. Create the application

    oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-1.1/samples/bookinfo/platform/kube/bookinfo.yaml
  4. Create the Gateway and the VirtuaService

    oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-1.1/samples/bookinfo/networking/bookinfo-gateway.yaml
  5. Check if the services and pods are up and running

    oc get svc,pods
    NAME                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
    service/details       ClusterIP   172.30.178.172   <none>        9080/TCP   7m16s
    service/productpage   ClusterIP   172.30.78.96     <none>        9080/TCP   7m13s
    service/ratings       ClusterIP   172.30.154.12    <none>        9080/TCP   7m15s
    service/reviews       ClusterIP   172.30.138.174   <none>        9080/TCP   7m14s
    
    NAME                                  READY   STATUS    RESTARTS   AGE
    pod/details-v1-d7db4d55b-mwzsk        2/2     Running   0          7m14s
    pod/productpage-v1-5f598fbbf4-svkbc   2/2     Running   0          7m11s
    pod/ratings-v1-85957d89d8-v2lrs       2/2     Running   0          7m11s
    pod/reviews-v1-67d9b4bcc-x6s2v        2/2     Running   0          7m11s
    pod/reviews-v2-67b465c497-zpz6z       2/2     Running   0          7m11s
    pod/reviews-v3-7bd659b757-j6rwn       2/2     Running   0          7m11s

Verify that application is accessible

  1. Export the Gateway URL into a variable

    export GATEWAY_URL=$(oc -n istio-system get route istio-ingressgateway -o jsonpath='{.spec.host}')
  2. Verify if the productpage is accessible

    curl -s http://${GATEWAY_URL}/productpage | grep -o "<title>.*</title>"
    <title>Simple Bookstore App</title>
  3. You can also access the Productpage in your browser. When you reload the page several times, you will see different results for the Reviews. This comes due to 3 different versions: one without any rating, one with black stars and one with red stars. http://${GATEWAY_URL}/productpage

    bookinfo productpage
    Figure 2. Bookinfo Application

Adding default Destination Rule

oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-1.1/samples/bookinfo/networking/destination-rule-all-mtls.yaml

This will add default routing to all endpoints with same weight. As you can see in Kiali, the Reviews microservice is contacted equally.

bookinfo kiali
Figure 3. Kiali: Bookinfo Application

Feel free to play with other DestinationRules to controll your traffic.