8.1 KiB
| title | overview | order | layout | type |
|---|---|---|---|---|
| BookInfo | This sample deploys a simple application composed of four separate microservices which will be used to demonstrate various features of the Istio service mesh. | 10 | docs | markdown |
{% include home.html %}
This sample deploys a simple application composed of four separate microservices which will be used to demonstrate various features of the Istio service mesh.
Before you begin
-
If you use GKE, please ensure your cluster has at least 4 standard GKE nodes.
-
Setup Istio by following the instructions in the Installation guide.
Overview
In this sample we will deploy a simple application that 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 so on), and a few book reviews.
The BookInfo application is broken into four separate microservices:
- productpage. The productpage microservice calls the details and reviews microservices to populate the page.
- details. The details microservice contains book information.
- reviews. The reviews microservice contains book reviews. It also calls the ratings microservice.
- ratings. The ratings microservice contains book ranking information that accompanies a book review.
There are 3 versions of the reviews microservice:
- Version v1 doesn't 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 below.
This application is polyglot, i.e., the microservices are written in different languages.
Start the application
-
Source the Istio configuration file from the root of the installation directory:
source istio.VERSION -
Change your current working directory to the
bookinfoapplication directory:cd demos/apps/bookinfo -
Bring up the application containers:
kubectl apply -f <(istioctl kube-inject -f bookinfo.yaml)The above command launches four microservices and creates the gateway ingress resource as illustrated in the diagram above. The reviews microservice has 3 versions: v1, v2, and v3.
Note that in a realistic deployment, new versions of a microservice are deployed over time instead of deploying all versions simultaneously.
Notice that the
istioctl kube-injectcommand is used to modify thebookinfo.yamlfile before creating the deployments. This injects Envoy into Kubernetes resources as documented here. Consequently, all of the microservices are now packaged with an Envoy sidecar that manages incoming and outgoing calls for the service. The updated diagram looks like this: -
Confirm all services and pods are correctly defined and running:
kubectl get serviceswhich produces the following output:
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE details 10.0.0.31 <none> 9080/TCP 6m istio-ingress 10.0.0.122 <pending> 80:31565/TCP 8m istio-manager 10.0.0.189 <none> 8080/TCP 8m istio-mixer 10.0.0.132 <none> 9091/TCP,42422/TCP 8m kubernetes 10.0.0.1 <none> 443/TCP 14d productpage 10.0.0.120 <none> 9080/TCP 6m ratings 10.0.0.15 <none> 9080/TCP 6m reviews 10.0.0.170 <none> 9080/TCP 6mand
kubectl get podswhich produces
NAME READY STATUS RESTARTS AGE details-v1-1520924117-48z17 2/2 Running 0 6m istio-ingress-3181829929-xrrk5 1/1 Running 0 8m istio-manager-175173354-d6jm7 2/2 Running 0 8m istio-mixer-3883863574-jt09j 2/2 Running 0 8m productpage-v1-560495357-jk1lz 2/2 Running 0 6m ratings-v1-734492171-rnr5l 2/2 Running 0 6m reviews-v1-874083890-f0qf0 2/2 Running 0 6m reviews-v2-1343845940-b34q5 2/2 Running 0 6m reviews-v3-1813607990-8ch52 2/2 Running 0 6m -
Determine the gateway ingress URL:
kubectl get ingress -o wide NAME HOSTS ADDRESS PORTS AGE gateway * 130.211.10.121 80 1d export GATEWAY_URL=130.211.10.121:80If your Kubernetes cluster is running in an environment that supports external load balancers, like for instance GKE, and the Istio ingress service was able to obtain an External IP, the ingress' resource IP Address will be equal to the ingress' service External IP. You can directly use that IP Address in your browser to access the http://$GATEWAY_URL/productpage.
If the service did not obtain an External IP, the ingress' IP Address will display a list of NodePort addresses. You can use any of these addresses to access the ingress, but if the cluster has a firewall, you will also need to create a firewall rule to allow TCP traffic to the NodePort. For instance, in GKE, create a firewall rule with these commands:
kubectl get svc istio-ingress -o jsonpath={.spec.ports[0].nodePort} 31201 gcloud compute firewall-rules create allow-book --allow tcp:31201 -
Confirm that the BookInfo application is running by opening in your browser http://$GATEWAY_URL/productpage , or with the following
curlcommand:curl -o /dev/null -s -w "%{http_code}\n" http://$GATEWAY_URL/productpage 200 -
If you have installed the Istio addons, in particular the servicegraph addon, from the Installation guide, a generated servicegraph of the cluster is available.
Get the external IP Address (and port) of the servicegraph service:
kubectl get svc servicegraph NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE servicegraph 10.75.240.195 104.196.248.114 8088:32556/TCP 23mThe servicegraph service provides both a textual (JSON) representation (via
/graph) and a graphical visualization (via/dotviz) of the underlying servicegraph.To view the graphical visualization, visit
http://EXTERNAL-IP:PORT/dotviz(here: http://104.196.248.114:8088/dotviz). After the singlecurlrequest from an earlier step, the resulting image will look something like:The servicegraph should show very low (or zero) QPS values, as only a single request has been sent. The service uses a default time window of 5 minutes for calculating moving QPS averages. Send a consistent flow of traffic through the example application and refresh the servicegraph to view updated QPS values that match the generated level of traffic.
What's next
Now that you have the BookInfo sample up and running, you can use Istio to control traffic routing, inject faults, rate limit services, etc..
-
To get started, check out the request routing task
-
When you're finished experimenting with the BookInfo sample, you can uninstall it as follows:
-
Delete the routing rules and terminate the application pods
./cleanup.sh -
Confirm shutdown
istioctl get route-rules #-- there should be no more routing rules kubectl get pods #-- the BookInfo pods should be deleted
