This is a cache of https://docs.openshift.com/container-platform/4.2/service_mesh/service_mesh_day_two/ossm-example-bookinfo.html. It is a snapshot of the page at 2024-11-23T02:40:13.929+0000.
Example application - Day Two | <strong>service</strong> Mesh | OpenShift Container Platform 4.2
×

The Bookinfo example application allows you to test your Red Hat OpenShift service Mesh 1.1.4 installation on OpenShift Container Platform.

Red Hat does not provide support for the Bookinfo application.

Bookinfo application

The upstream Istio project has an example tutorial called Bookinfo, which is composed of four separate microservices used to demonstrate various Istio features. 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.

Installing the Bookinfo application

This tutorial walks you through creating a Bookinfo project, deploying the Bookinfo application, and running Bookinfo on OpenShift Container Platform with service Mesh 1.1.4.

Prerequisites:
  • OpenShift Container Platform 4.1 or higher installed.

  • Red Hat OpenShift service Mesh 1.1.4 installed.

  • Access to the OpenShift Container Platform Command-line Interface (CLI) also known as oc.

Red Hat OpenShift service Mesh implements auto-injection differently than the upstream Istio project, therefore this procedure uses a version of the bookinfo.yaml file annotated to enable automatic injection of the Istio sidecar for Red Hat OpenShift service Mesh.

Procedure
  1. Log in to the OpenShift Container Platform web console as a user with cluster-admin rights.

  2. Click to HomeProjects.

  3. Click Create Project.

  4. Enter bookinfo as the Project Name, enter a Display Name, and enter a Description, then click Create.

    • Alternatively, you can run this command from the CLI to create the bookinfo project.

      $ oc new-project bookinfo
  5. Click OperatorsInstalled Operators.

  6. Click the Project menu and use the control plane namespace. In this example, use istio-system.

  7. Click the Red Hat OpenShift service Mesh Operator.

  8. Click the Istio service Mesh Member Roll link.

    1. If you have already created a Istio service Mesh Member Roll, click the name, then click the YAML tab to open the YAML editor.

    2. If you have not created a Istio service Mesh Member Roll, click Create service Mesh Member Roll.

      You need cluster-admin rights to edit the Istio service Mesh Member Roll.

  9. Edit the default service Mesh Member Roll YAML and add bookinfo to the members list.

    Bookinfo serviceMeshMemberRoll example
      apiVersion: maistra.io/v1
      kind: serviceMeshMemberRoll
      metadata:
        name: default
      spec:
        members:
        - bookinfo
    • Alternatively, you can run this command from the CLI to add the bookinfo project to the serviceMeshMemberRoll. Replace <control plane project> with the name of your control plane project.

      $ oc -n <control plane project> patch --type='json' smmr default -p '[{"op": "add", "path": "/spec/members", "value":["'"bookinfo"'"]}]'
  10. Click Create to save the updated service Mesh Member Roll.

  11. From the CLI, deploy the Bookinfo application in the `bookinfo` project by applying the bookinfo.yaml file:

    $ oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-1.1/samples/bookinfo/platform/kube/bookinfo.yaml
  12. Create the ingress gateway by applying the bookinfo-gateway.yaml file:

    $ oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-1.1/samples/bookinfo/networking/bookinfo-gateway.yaml
  13. Set the value for the GATEWAY_URL parameter:

    Replace <control_plane_project> with the name of your control plane project. In this example, the control plane project is istio-system.

    $ export GATEWAY_URL=$(oc -n <control_plane_project> get route istio-ingressgateway -o jsonpath='{.spec.host}')

Adding default destination rules

Before you can use the Bookinfo application, you have to add default destination rules. There are two preconfigured YAML files, depending on whether or not you enabled mutual transport layer security (TLS) authentication.

Procedure
  1. To add destination rules, run one of the following commands:

    • If you did not enable mutual TLS:

      $ oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-1.1/samples/bookinfo/networking/destination-rule-all.yaml
    • If you enabled mutual TLS:

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

Verifying the Bookinfo installation

Before configuring your application, verify that it successfully deployed.

Prerequisites
  • OpenShift Container Platform 4.1 or higher installed.

  • Red Hat OpenShift service Mesh 1.1.4 installed.

  • Access to the OpenShift Container Platform Command-line Interface (CLI) also known as oc.

Procedure
  1. Log in to the OpenShift Container Platform CLI.

  2. Run this command to confirm that Bookinfo is deployed:

    $ curl -o /dev/null -s -w "%{http_code}\n" http://$GATEWAY_URL/productpage
    • Alternatively, you can open http://$GATEWAY_URL/productpage in your browser.

    • You can also verify that all pods are ready with this command:

      $ oc get pods -n bookinfo

Removing the Bookinfo application

Follow these steps to remove the Bookinfo application.

Prerequisites
  • OpenShift Container Platform 4.1 or higher installed.

  • Red Hat OpenShift service Mesh 1.1.4 installed.

  • Access to the OpenShift Container Platform Command-line Interface (CLI) also known as oc.

Delete the Bookinfo project

Procedure
  1. Log in to the OpenShift Container Platform web console.

  2. Click to HomeProjects.

  3. Click on the bookinfo menu kebab, and then click Delete Project.

  4. Type bookinfo in the confirmation dialog box, and then click Delete.

    • Alternatively, you can run this command from the CLI to create the bookinfo project.

      $ oc delete project bookinfo

Remove the Bookinfo project from the service Mesh member roll

Procedure
  1. Log in to the OpenShift Container Platform web console.

  2. Click OperatorsInstalled Operators.

  3. Click the Project menu and choose openshift-operators from the list.

  4. Click the Istio service Mesh Member Roll link under Provided APIS for the Red Hat OpenShift service Mesh Operator.

  5. Click the serviceMeshMemberRoll menu kebab and select Edit service Mesh Member Roll.

  6. Edit the default service Mesh Member Roll YAML and remove bookinfo from the members list.

    • Alternatively, you can run this command from the CLI to remove the bookinfo project from the serviceMeshMemberRoll. Replace <control plane project> with the name of your control plane project.

      $ oc -n <control plane project> patch --type='json' smmr default -p '[{"op": "remove", "path": "/spec/members", "value":["'"bookinfo"'"]}]'
  7. Click Save to update service Mesh Member Roll.