Bookinfo Application
This example deploys a sample application composed of four separate microservices used to demonstrate various Istio features.
The 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 so on), and a few book reviews.
The Bookinfo application is broken into four separate microservices:
productpage
. Theproductpage
microservice calls thedetails
andreviews
microservices to populate the page.details
. Thedetails
microservice contains book information.reviews
. Thereviews
microservice contains book reviews. It also calls theratings
microservice.ratings
. Theratings
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.
It’s worth noting that these services have no dependencies on Istio, but make an interesting
service mesh example, particularly because of the multitude of services, languages and versions
for the reviews
service.
Before you begin
If you haven’t already done so, setup Istio by following the instructions in the installation guide5.
Deploying the application
To run the sample with Istio requires no changes to the application itself. Instead, you simply need to configure and run the services in an Istio-enabled environment, with Envoy sidecars injected along side each service. The resulting deployment will look like this:
All of the microservices will be packaged with an Envoy sidecar that intercepts incoming and outgoing calls for the services, providing the hooks needed to externally control, via the Istio control plane, routing, telemetry collection, and policy enforcement for the application as a whole.
Start the application services
Change directory to the root of the Istio installation.
The default Istio installation uses automatic sidecar injection. Label the namespace that will host the application with
istio-injection=enabled
:Deploy your application using the
kubectl
command:The command launches all four services shown in the
bookinfo
application architecture diagram. All 3 versions of the reviews service, v1, v2, and v3, are started.Confirm all services and pods are correctly defined and running:
and
To confirm that the Bookinfo application is running, send a request to it by a
curl
command from some pod, for example fromratings
:
Determine the ingress IP and port
Now that the Bookinfo services are up and running, you need to make the application accessible from outside of your Kubernetes cluster, e.g., from a browser. A gateway is used for this purpose.
Create a gateway for the Bookinfo application:
Create an Istio Gateway using the following command:
Confirm the gateway has been created:
Follow these instructions to set the
INGRESS_HOST
andINGRESS_PORT
variables for accessing the gateway. Return here, when they are set.Create a Kubernetes Gateway9 using the following command:
Because creating a Kubernetes
Gateway
resource will also deploy an associated proxy service, run the following command to wait for the gateway to be ready:Get the gateway address and port from the bookinfo gateway resource:
Set
GATEWAY_URL
:
Confirm the app is accessible from outside the cluster
To confirm that the Bookinfo application is accessible from outside the cluster, run the following curl
command:
You can also point your browser to http://$GATEWAY_URL/productpage
to view the Bookinfo web page. If you refresh the page several times, you should
see different versions of reviews shown in productpage
, presented in a round robin style (red
stars, black stars, no stars), since we haven’t yet used Istio to control the
version routing.
Define the service versions
Before you can use Istio to control the Bookinfo version routing, you need to define the available versions.
Istio uses subsets, in destination rules, to define versions of a service. Run the following command to create default destination rules for the Bookinfo services:
Wait a few seconds for the destination rules to propagate.
You can display the destination rules with the following command:
Unlike the Istio API, which uses DestinationRule
subsets to define the versions of a service,
the Kubernetes Gateway API uses backend service definitions for this purpose.
Run the following command to create backend service definitions for the three versions of the reviews
service:
What’s next
You can now use this sample to experiment with Istio’s features for traffic routing, fault injection, rate limiting, etc. To proceed, refer to one or more of the Istio Tasks14, depending on your interest. Configuring Request Routing15 is a good place to start for beginners.
Cleanup
When you’re finished experimenting with the Bookinfo sample, uninstall and clean it up using the following command: