loader

Application: Istio Bookinfo
Introduction

Istio Bookinfo (Bookinfo Application) is a sample application from Istio composed of four separate microservices intended to demonstrate various Istio features. In this guide, we will use Istio Bookinfo to demonstrate inter-slice communications.

Prerequisites
Note
These instructions will guide you through deploying the Product Page service to a cluster we will refer to as the , and the remaining services as well as service exports will be deployed to a cluster referred to here as the .

To install Istio Bookinfo, you should first have a KubeSlice configuration with two or more cluster completely installed. If you need to install KubeSlice, visit:

Getting Started

Creating the Bookinfo Deployment .yaml Files

Using the templates below, create the necessary .yaml files to deploy the Bookinfo application. All fields in the template will remain the same except for the <slice name> which must be replaced with the name of your KubeSlice configuration.

Product Page

Using the template below, create productpage.yaml. All fields in the template will remain the same except for the <slice name> which must be replaced with the name of your slice:

##################################################################################
# ProductPage Service
##################################################################################
apiVersion: v1
kind: Service
metadata:
  name: productpage
  namespace: bookinfo
  labels:
    app: productpage
    service: productpage
spec:
  type: NodePort
  ports:
  - port: 9080
    name: http
  selector:
    app: productpage
---
#ProductPage ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: bookinfo-productpage
  labels:
    account: productpage
---
#ProductPage Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: productpage-v1
  annotations:
    avesha.io/slice: <slice name> #Replace Slice Name
  labels:
    app: productpage
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: productpage
      version: v1
  template:
    metadata:
      labels:
        app: productpage
        version: v1
    spec:
      serviceAccountName: bookinfo-productpage
      containers:
      - name: productpage
        image: docker.io/istio/examples-bookinfo-productpage-v1:1.16.2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
        volumeMounts:
        - name: tmp
          mountPath: /tmp
        securityContext:
          runAsUser: 1000
        env:
        - name: REVIEWS_HOSTNAME
          value: reviews.bookinfo.svc.slice.local
        - name: DETAILS_HOSTNAME
          value: details.bookinfo.svc.slice.local
      - name: netshoot
        image: nicolaka/netshoot
        imagePullPolicy: IfNotPresent
        command: ["/bin/sleep", "3650d"]
        securityContext:
          capabilities:
            add: ["NET_ADMIN"]
          allowPrivilegeEscalation: true
          privileged: true
      volumes:
      - name: tmp
        emptyDir: {}

Details

Using the template below, create details.yaml. All fields in the template will remain the same except for the <slice name> which must be replaced with the name of your slice:

##################################################################################
# Details Service
##################################################################################
apiVersion: v1
kind: Service
metadata:
  name: details
  labels:
    app: details
    service: details
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: details
---
#Details ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: bookinfo-details
  labels:
    account: details
---
#Details Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: details-v1
  annotations:
    avesha.io/slice: <slice name> #Replace Slice Name
  labels:
    app: details
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: details
      version: v1
  template:
    metadata:
      labels:
        app: details
        version: v1
    spec:
      serviceAccountName: bookinfo-details
      containers:
      - name: details
        image: docker.io/istio/examples-bookinfo-details-v1:1.16.2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
        securityContext:
          runAsUser: 1000
      - name: netshoot
        image: nicolaka/netshoot
        imagePullPolicy: IfNotPresent
        command: ["/bin/sleep", "3650d"]
        securityContext:
          capabilities:
            add: ["NET_ADMIN"]
          allowPrivilegeEscalation: true
          privileged: true

Ratings

Using the template below, create ratings.yaml. All fields in the template will remain the same except for the <slice name> which must be replaced with the name of your slice:

##################################################################################
# Ratings Service
##################################################################################
apiVersion: v1
kind: Service
metadata:
  name: ratings
  labels:
    app: ratings
    service: ratings
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: ratings
---
#Ratings ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: bookinfo-ratings
  labels:
    account: ratings
---
#Ratings Deploym
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ratings-v1
  annotations:
    avesha.io/slice: <slice name>  #Replace Slice Name
  labels:
    app: ratings
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ratings
      version: v1
  template:
    metadata:
      labels:
        app: ratings
        version: v1
    spec:
      serviceAccountName: bookinfo-ratings
      containers:
      - name: ratings
        image: docker.io/istio/examples-bookinfo-ratings-v1:1.16.2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
        securityContext:
          runAsUser: 1000
      - name: netshoot
        image: nicolaka/netshoot
        imagePullPolicy: IfNotPresent
        command: ["/bin/sleep", "3650d"]
        securityContext:
          capabilities:
            add: ["NET_ADMIN"]
          allowPrivilegeEscalation: true
          privileged: true

EOF

Reviews

Using the template below, create reviews.yaml. All fields in the template will remain the same except for the <slice name> which must be replaced with the name of your slice:

##################################################################################
# Reviews Service
##################################################################################
apiVersion: v1
kind: Service
metadata:
  name: reviews
  labels:
    app: reviews
    service: reviews
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: reviews
---
#Reviews ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: bookinfo-reviews
  labels:
    account: reviews
---
#Reviews Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: reviews-v3
  annotations:
    avesha.io/slice: <slice name>  #Replace Slice Name
  labels:
    app: reviews
    version: v3
spec:
  replicas: 1
  selector:
    matchLabels:
      app: reviews
      version: v3
  template:
    metadata:
      labels:
        app: reviews
        version: v3
    spec:
      serviceAccountName: bookinfo-reviews
      containers:
      - name: reviews
        image: docker.io/istio/examples-bookinfo-reviews-v3:1.16.2
        imagePullPolicy: IfNotPresent
        env:
        - name: LOG_DIR
          value: "/tmp/logs"
        ports:
        - containerPort: 9080
        volumeMounts:
        - name: tmp
          mountPath: /tmp
        - name: wlp-output
          mountPath: /opt/ibm/wlp/output
        securityContext:
          runAsUser: 1000
      - name: netshoot
        image: nicolaka/netshoot
        imagePullPolicy: IfNotPresent
        command: ["/bin/sleep", "3650d"]
        securityContext:
          capabilities:
            add: ["NET_ADMIN"]
          allowPrivilegeEscalation: true
          privileged: true
      volumes:
      - name: wlp-output
        emptyDir: {}
      - name: tmp
        emptyDir: {}

ServiceExports

Using the template below, create serviceexports.yaml. All fields in the template will remain the same except for two <slice name> instances which must be replaced with the name of your slice:

##################################################################################
# Details ServiceExport
##################################################################################
apiVersion: mesh.avesha.io/v1beta1
kind: ServiceExport
metadata:
  name: details
spec:
  slice: <slice name>  #Replace Slice Name
  selector:
    matchLabels:
      app: details
  meshType: none
  ingressEnabled: false
  ports:
  - name: http
    containerPort: 9080
    protocol: TCP
---
##################################################################################
# Reviews ServiceExport
##################################################################################
apiVersion: mesh.avesha.io/v1beta1
kind: ServiceExport
metadata:
  name: reviews
spec:
  slice: <slice name>  #Replace Slice Name
  selector:
    matchLabels:
      app: reviews
  meshType: none
  ingressEnabled: false
  ports:
  - name: http
    containerPort: 9080
    protocol: TCP
Deploying to the Product Page Cluster

First, we will use the below command to ensure we are targeting the cluster we will be deploying the product page to:

kubectx <services cluster>

Using the command below create the bookinfo namespace that we will deploy these services on:

kubectl create ns bookinfo

Next using the below command, apply the productpage.yaml file:

kubectl apply -f productpage.yaml -n bookinfo

Expected:

service/productpage created
serviceaccount/bookinfo-productpage created
deployment.apps/productpage-v1 created

Lastly, check to see that the deployed productpage pod is running on the cluster:

kubectl get pods -n bookinfo

Expected:

NAME                             READY   STATUS    RESTARTS   AGE
productpage-v1-587d8cc7f-mbdkn   4/4     Running   0          41s
Deploying to the Services Cluster

First, we will use the below command to ensure we are targeting the cluster we will be deploying reviews, details, and ratings to:

kubectx <services cluster>

Using the command below create the bookinfo namespace that we will deploy these services on:

kubectl create ns bookinfo

We will then use the below command to label the bookinfo namespace for istio-injection:

kubectl label namespace bookinfo istio-injection=enabled

Next using the below commands, apply the details.yaml, ratings.yaml, reviews.yaml, and serviceexports.yaml files.

details.yaml:

kubectl apply -f details.yaml -n bookinfo

Expected:

service/details created
serviceaccount/bookinfo-details created
deployment.apps/details-v1 created

ratings.yaml

kubectl apply -f ratings.yaml -n bookinfo

Expected:

service/ratings created
serviceaccount/bookinfo-ratings created
deployment.apps/ratings-v1 created

reviews.yaml:

kubectl apply -f reviews.yaml -n bookinfo

Expected:

service/reviews created
serviceaccount/bookinfo-reviews created
deployment.apps/reviews-v3 created

Quickly check to see the deployed pods are running on the cluster:

kubectl get pods -n bookinfo

Expected:

NAME                          READY   STATUS    RESTARTS   AGE
details-v1-f884f7554-7wbk9    4/4     Running   0          94s
ratings-v1-7c9c45b4b6-4lhvq   4/4     Running   0          91s
reviews-v3-567b6d4dcd-rhnsm   4/4     Running   0          88s

serviceexports.yaml

kubectl apply -f serviceexports.yaml -n bookinfo

Expected:

serviceexport.mesh.avesha.io/details created
serviceexport.mesh.avesha.io/reviews created
Verifying the Bookinfo Deployment

Verifying the Services Cluster

To verify the Bookinfo installation, we will first switch contexts to target the <services cluster>:

kubectx <services cluster>

Use the below command to verify the details and reviews services have been successfully exported to the KubeSlice configuration:

kubectl get serviceexport -n bookinfo

Expected:

NAME     SLICE         INGRESS  PORT(S)   ENDPOINTS  STATUS
details  <slice name>           9080/TCP  1          READY
reviews  <slice name>           9080/TCP  1          READY

Verifying the Product Page Cluster

Next, we will switch contexts to target the <productpage cluster>:

kubectx <productpage cluster>

Using the below command, verify the details and reviews service imports are present in the cluster:

kubectl get si -n bookinfo

Expected:

NAME     SLICE         PORT(S)   ENDPOINTS  STATUS
details  <slice name>  9080/TCP  1          READY
reviews  <slice name>  9080/TCP  1          READY

Next, use the below command to check the exposed port for the product page service. In a moment, you will use this port to visit the Bookinfo webpage:

kubectl get services -n bookinfo

Expected:

NAME         TYPE      CLUSTER-IP    EXTERNAL-IP  PORT(S)         AGE
productpage  NodePort  192.144.4.64  <none>       9080:30274/TCP  8m13s

To view the deployed Bookinfo product page, we need the external IP of an application node, as well as the exposed port we just retrieved. Use the below command to get your node details, and take note of the external IP of one of the application nodes:

kubectl get nodes -o wide

Expected (yours will differ, here we are just focused on the external IP value):

NAME                        STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP      
avesha-demo-node-b5c436f6   Ready    <none>   41h   v1.21.4   192.144.32.9    34.138.156.1     
avesha-demo-node-fb883fb4   Ready    <none>   41h   v1.21.4   192.144.32.6    35.231.127.166   
avesha-gateway-n-71ca402c   Ready    <none>   40h   v1.21.4   192.144.32.10   34.139.61.46     
avesha-gateway-n-76f8d658   Ready    <none>   40h   v1.21.4   192.144.32.11   34.139.147.208   

Combine the external IP the command returns with the port you retrieved in the last step in the format below, and visit the page in a browser to view your multicluster Bookinfo deployment:

http://<external ip>:<port>/productpage
Note
You have successfully deployed Istio Bookinfo on a KubeSlice configuration containing at least two clusters.
Uninstalling Istio Bookinfo

If you would like to uninstall Istio Bookinfo from your KubeSlice configuration, simply follow the instructions in the guide below:


< PREVIOUS
Application: iPerf iPerf is a tool commonly used to measure network performance, perform network tuning, and more. The iPerf application is made up of two main services, iperf-sleep (client) and iperf-server. This guide will show the installation of the iperf-sleep and iperf-server services on two clusters within a KubeSlice configuration. Additionally, you will be able to use the installed iPerf tool to verify cross cluster communication over the KubeSlice. Read More
NEXT >
Uninstalling KubeSlice There are three main steps to uninstalling KubeSlice: Detaching Applications, Uninstalling Slices, and Uninstalling the Slice Operator. Avesha has compiled the below guide to walk you through uninstalling a KubeSlice slice. Read More