Deploying the Bookinfo Application
TOC
An Overview of the Bookinfo Application
To install the bookinfo sample application, two primary steps are required: first, deploying the application itself, and second, setting up a gateway to make it accessible from outside the cluster.
The bookinfo application serves as a tool for exploring the features of a service mesh. It allows you to easily verify that web browser requests are correctly routed through the mesh to the application.
The bookinfo application presents information about a book, much like a single entry in an online bookstore's catalog. It shows a page with a book description, its details (such as ISBN and page count), and customer reviews.
When exposed through the mesh, the behavior of the bookinfo application's microservices is governed by the mesh configuration. The review data is sourced from one of three services: reviews-v1, reviews-v2, or reviews-v3. If you deploy bookinfo without a defined reviews virtual service, the mesh defaults to a round-robin policy for routing requests to these services.
By creating a reviews virtual service, you can define custom routing rules. For instance, you could configure the mesh to direct requests to the reviews-v2 service when a user is logged in, which would display reviews with black stars. Conversely, for users who are not logged in, the mesh could route requests to reviews-v3, showing reviews with red stars.
Additional details can be found in the upstream Istio documentation for the Bookinfo Application.
Deploying the Bookinfo Application
Prerequisites
- Alauda Service Mesh v2 Operator is installed.
- An Istio CNI is deployed.
- An Istio control plane is deployed.
Procedure
-
Use the following command to Create a new namespace named
bookinfo: -
Enable sidecar injection for the
bookinfonamespace. If your setup uses theInPlaceupgrade strategy, run this command:NOTEIf you are using the
RevisionBasedupgrade strategy, execute these commands:-
To discover your
<revision-name>, run the following:Sample output:
-
Label the namespace using the revision name to enable sidecar injection:
-
-
Optional : If you have already configured
discoverySelectors, use the following command to apply the Istiodiscovery selectorto thebookinfonamespace:Example
discovery selectorlabel:istio-discovery=enabled -
Deploy the
bookinfoapplication by applying its YAML file with the following command:
Verification
-
To confirm the
bookinfoservice is available, run this command:Example output
-
To check that the
bookinfopods are available, execute the following command:Example output
A successful proxy sidecar injection is indicated when the
Readycolumn shows2/2. Ensure theStatuscolumn for each pod showsRunning. -
Confirm the
bookinfoapplication is running by sending a request to itsproduct page. Execute this command:Example output
Accessing the Bookinfo Application via a Gateway
Gateways are not deployed by the Alauda Service Mesh v2 Operator because they are not considered part of the control plane. For security, it is a best practice to deploy Ingress and Egress gateways in a separate namespace from the control plane.
There are two methods for deploying gateways: using the Gateway API or the gateway injection technique.
Accessing the Bookinfo Application with Istio Gateway Injection
The gateway injection technique leverages the same mechanism as Istio sidecar injection. It creates a gateway from a Deployment resource that is associated with a Service resource. This Service can then be exposed outside the Alauda Container Platform cluster.
Prerequisites
- Alauda Service Mesh v2 Operator is installed.
- An Istio control plane is deployed.
Procedure
-
Execute the following command to create the
istio-ingressgatewaydeployment and service: -
Configure the
bookinfoapplication to use the newly created gateway by running this command:NOTEThis example uses a sample gateway configuration file to set up gateway injection for the
bookinfoapplication. The file must be applied in the same namespace where the application is installed. -
Optional : Modify the YAML file for automatic pod scaling based on ingress traffic.
Example configuration
- In this example, the maximum replica count is set to
5and the minimum to2. A new replica is created when CPU utilization hits 80%.
- In this example, the maximum replica count is set to
-
Optional : Define the minimum number of pods that should be running on the node.
Example configuration
- This example configuration makes sure at least one replica is running if a pod is restarted on a different node.
Verification
You will connect to the Bookinfo productpage service through the gateway you just provisioned. To access the gateway, you need to use the kubectl port-forward command:
- If you run the command locally on your workstation, open
http://localhost:9080/productpagein your browser. - If you ran the command on a remote IPv4 host and used
--address "0.0.0.0", replacelocalhostwith the remote host's IP or hostname (for examplehttp://<REMOTE_HOST_IP>:9080/productpage) - If you ran the command on a remote IPv6 host and used
--address "::", replacelocalhostwith the remote host's IP or hostname (for examplehttp://[<REMOTE_HOST_IP>]:9080/productpage)
When 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.
Accessing the Bookinfo Application with the Gateway API
With the Kubernetes Gateway API, a gateway is deployed through the creation of a Gateway resource.
Prerequisites
- Alauda Service Mesh v2 Operator is installed.
- An Istio control plane is deployed.
- Your Kubernetes cluster supports external load balancers (i.e., Services of type
LoadBalancer)
Procedure
-
Create and configure a gateway with the
GatewayandHTTPRouteresources by executing the command below:NOTEThis example uses a sample gateway configuration file to configure a gateway for the
bookinfoapplication via the Gateway API. This file must be applied in the application's namespace. -
Ensure the Gateway API service is ready and has an address by running the following command:
-
Retrieve the host with this command:
-
Retrieve the port with this command:
-
Retrieve the gateway URL with this command:
INFOIf
$INGRESS_HOSTis an IPv6 address, enclose it in square brackets when constructing the URL. For example: -
Get the full URL for the product page by running the following command:
Verification
-
Confirm that the productpage is accessible with the
curlcommand:Example output
-
Confirm that the productpage is accessible in a web browser.
Point your browser to
http://${GATEWAY_URL}/productpageto view the Bookinfo web page.When 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.