Create and configure a project for the service mesh

Now, let’s proceed with deploying a workload to test our service mesh.

  1. First, let’s create a project (namespace) for us to deploy our workload into. To do so, run the following command:

    oc new-project bookinfo
    Sample Output
    Now using project "bookinfo" on server "https://api.rosa-6n4s8.1c1c.p1.openshiftapps.com:6443".
    
    You can add applications to this project with the 'new-app' command. For example, try:
    
        oc new-app rails-postgresql-example
    
    to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application:
    
        kubectl create deployment hello-node --image=k8s.gcr.io/e2e-test-images/agnhost:2.33 -- /agnhost serve-hostname
  2. Next, let’s label that project (namespace) to enable the service mesh injection for all applications in the project.

    oc label namespace bookinfo istio-injection=enabled
    Sample Output
    namespace/bookinfo labeled
  3. Even though we’ve enabled service mesh injection in the project, we also need to add our project (namespace) to the ServiceMeshMemberRoll, which limits the scope of the service mesh control plane to only projects in the member roll. To add the project to the ServiceMeshMemberRoll, run the following command:

    cat << EOF | oc apply -f -
    ---
    apiVersion: maistra.io/v1
    kind: ServiceMeshMemberRoll
    metadata:
      name: default
      namespace: istio-system
    spec:
      members:
      - bookinfo
    EOF
    Sample Output
    servicemeshmemberroll.maistra.io/default created
  4. Next, let’s verify the ServiceMeshMemberRoll was created successfully. To do so, run the following command:

    oc -n istio-system get smmr -o wide
    Sample Output
    NAME      READY   STATUS       AGE   MEMBERS
    default   1/1     Configured   20s   ["bookinfo"]

    The service mesh member roll was successfully configured when the STATUS column is Configured and your project shows up in the MEMBERS column.

Deploy our test workload

  1. Now that we’ve configured the service mesh for our project, let’s deploy our bookinfo workload into our project. To do so, run the following command to create the necessary resources:

    oc -n bookinfo apply -f \
      https://raw.githubusercontent.com/rh-mobb/rosa-workshop-content/main/rosa-content/assets/scripts/bookinfo.yaml
    Sample Output
    service/details created
    serviceaccount/bookinfo-details created
    deployment.apps/details-v1 created
    service/ratings created
    serviceaccount/bookinfo-ratings created
    deployment.apps/ratings-v1 created
    service/reviews created
    serviceaccount/bookinfo-reviews created
    deployment.apps/reviews-v1 created
    deployment.apps/reviews-v2 created
    deployment.apps/reviews-v3 created
    service/productpage created
    serviceaccount/bookinfo-productpage created
    deployment.apps/productpage-v1 created

    You may ignore any warnings.

    Interested in seeing the configuration you’re deploying? Check it out on GitHub here.

  2. Now, let’s create the service mesh ingress gateway. To do so, run the following command:

    oc -n bookinfo apply -f \
      https://raw.githubusercontent.com/rh-mobb/rosa-workshop-content/main/rosa-content/assets/scripts/bookinfo-gateway.yaml
    Sample Output
    gateway.networking.istio.io/bookinfo-gateway created
    virtualservice.networking.istio.io/bookinfo created
  3. Next, let’s add some destination rules. Destination rules define policies that apply to traffic intended for a service after routing has occurred. To create the rules, run the following command:

    oc -n bookinfo apply -f \
      https://raw.githubusercontent.com/rh-mobb/rosa-workshop-content/main/rosa-content/assets/scripts/destination-rule-all.yaml
    Sample Output
    destinationrule.networking.istio.io/productpage created
    destinationrule.networking.istio.io/reviews created
    destinationrule.networking.istio.io/ratings created
    destinationrule.networking.istio.io/details created

Verifying the Bookinfo installation

  1. First, let’s verify that all pods are running and ready by running the following command:

    oc -n bookinfo get pods
    Sample Output
    NAME                              READY   STATUS    RESTARTS   AGE
    details-v1-7d55897577-gvwm5       2/2     Running   0          98s
    productpage-v1-8648b7c9b5-txfvk   2/2     Running   0          96s
    ratings-v1-84599899df-twc8g       2/2     Running   0          97s
    reviews-v1-59647cf6c-pbrn8        2/2     Running   0          97s
    reviews-v2-5fc469b4ff-fp4fn       2/2     Running   0          97s
    reviews-v3-7d84688cc9-kktpt       2/2     Running   0          97s
  2. Next, let’s get the URL for the product page. To do so, run the following command:

    echo "http://$(oc -n istio-system get route istio-ingressgateway -o jsonpath='{.spec.host}')/productpage"
    Sample Output
    http://istio-ingressgateway-istio-system.apps.rosa-6n4s8.1c1c.p1.openshiftapps.com/productpage
  3. Copy and paste the URL provided in the previous step into your web browser and verify the Bookinfo product page is successfully deployed. Remember, if you get "Application not found" check to see if your browser has changed your http to and https!

    You should see a book review of "The Comedy of Errors".