This is the 12th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Published in isTIO Practice Manual

Deploy the official Bookinfo sample application.

The example deplores an application that demonstrates a variety of Istio features and consists of four separate microservices. The app mimics a category in an online bookstore and displays information about a book. The page displays a description of the book, details of the book (ISBN, page number, etc.), and some reviews about the book.

The Bookinfo application is divided into four separate microservices:

  • productpage: The microservice will be calleddetails 和 reviewsTwo microservices for generating pages.
  • details: This microservice contains information about books.
  • reviews: This micro-service contains book related reviews. It also callsratingsThe service.
  • ratings: This micro-service contains rating information composed of book reviews.

Reviews Microservices comes in 3 versions:

  • V1 version will not be calledratingsService.
  • The v2 version callsratingsService, and use one to five black star ICONS to display scoring information.
  • V3 will callratingsService, and use 1 to 5 red star ICONS to display scoring information.

The following figure shows the end-to-end architecture of the application.

Figure 5.3.1: Bookinfo deployment diagram

1. Deploy the service

  1. The Istio installation directory is displayed.

  2. Istio automatically injects sidecar by default. Please label the default namespace istio-injection=enabled:

    $ kubectl label namespace default istio-injection=enabled
    namespace/default labeled
    Copy the code
  3. Kubectl apply -f

    kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
    Copy the code
  4. Verify that all services and pods are properly defined and started:

    kubectl get service
    
    kubectl get pod
    Copy the code
  5. To verify that the Bookinfo app is running, send a request to the app with curl in a Pod, such as ratings:

    kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}') -c ratings -- curl productpage:9080/productpage | grep -o "<title>.*</title>"
    Copy the code

2. Determine the IP address and port of the Ingress

Now that all the services in Bookinfo are up and running, you need to make your application accessible externally, for example using a browser. You can achieve this with the Istio Gateway.

  1. Define the Ingress gateway for your application

    kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
    Copy the code
  2. Ensure that the gateway is created

    $ kubectl get gateway
    NAME               AGE
    bookinfo-gateway   32s
    Copy the code
  3. Confirm the IP address and port of the Ingress

    Run the following command to make sure that the Kubernetes cluster environment supports external load balancing:

    kubectl get svc istio-ingressgateway -n istio-system
    Copy the code

    If the external-ip value is present, the environment is using an EXTERNAL load balancer that can be used to serve the Ingress Gateway. If the external-ip value is < None > (or is displayed continuously), the environment does not provide EXTERNAL load balancing and the ingress Gateway cannot be used. You can set the value of external-ip for EXTERNAL access.

  4. Set the EXTERNAL – IP

    Run the following command to set the value of external-ip, that is, to the IP address of the master.

    kubectl edit  service istio-ingressgateway -n istio-system
    Copy the code

    Figure 5.3.2: External-IP Settings

    Check whether the external-IP value of istio-ingressgateway is set successfully.

    kubectl get  service istio-ingressgateway -n istio-system
    Copy the code

3. Ensure that applications can be accessed from outside the cluster

Open http://< external-ip >/ productPage in a browser to browse the Web page of the application. If you refresh the app’s page a few times, you’ll see that the productPage page randomly displays different versions of the Reviews service (red, black stars or none). This happens with the Reviews service because we haven’t used Istio to control version routing.

Figure 5.3.3: BookInfo application page

In Istio learning, you can use this example to verify Istio functions such as traffic routing and fault injection.

4. Uninstall the sample application

When you have finished experimenting with the Bookinfo example, follow these instructions to uninstall and clean it up if necessary:

  1. Delete the routing rule and terminate the application container

    samples/bookinfo/platform/kube/cleanup.sh
    Copy the code
  2. Confirm the uninstall

    kubectl get virtualservices   #-- there should be no virtual services
    kubectl get destinationrules  #-- there should be no destination rules
    kubectl get gateway           #-- there should be no gateway
    kubectl get pods              #-- the Bookinfo pods should be deleted
    Copy the code

\