https://istio.io/docs/examples/bookinfo/

Start the application services

  1. Change directory to the root of the Istio installation.

  2. The default Istio installation uses automatic sidecar injection. Label the namespace that will host the application with istio-injection=enabled:

$ kubectl label namespace default istio-injection=enabled

1
If you use OpenShift, make sure to give appropriate permissions to service accounts on the namespace as described in OpenShift setup page.
  1. Deploy your application using the kubectl command:

$ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml

1
2
3
If you disabled automatic sidecar injection during installation and rely on manual sidecar injection, use the istioctl kube-inject command to modify the bookinfo.yaml file before deploying your application.

$ kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)

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.

In a realistic deployment, new versions of a microservice are deployed over time instead of deploying all versions simultaneously.

  1. Confirm all services and pods are correctly defined and running:
1
2
3
4
5
6
7
$ kubectl get services
NAME                       CLUSTER-IP   EXTERNAL-IP   PORT(S)              AGE
details                    10.0.0.31    <none>        9080/TCP             6m
kubernetes                 10.0.0.1     <none>        443/TCP              7d
productpage                10.0.0.120   <none>        9080/TCP             6m
ratings                    10.0.0.15    <none>        9080/TCP             6m
reviews                    10.0.0.170   <none>        9080/TCP             6m

and

1
2
3
4
5
6
7
8
$ kubectl get pods
NAME                                        READY     STATUS    RESTARTS   AGE
details-v1-1520924117-48z17                 2/2       Running   0          6m
productpage-v1-560495357-jk1lz              2/2       Running   0          6m
ratings-v1-734492171-rnr5l                  2/2       Running   0          6m
reviews-v1-874083890-f0qf0                  2/2       Running   0          6m
reviews-v2-1343845940-b34q5                 2/2       Running   0          6m
reviews-v3-1813607990-8ch52                 2/2       Running   0          6m
  1. To confirm that the Bookinfo application is running, send a request to it by a curl command from some pod, for example from ratings:

$ kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath=’{.items[0].metadata.name}') -c ratings – curl productpage:9080/productpage | grep -o “.*

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. An Istio Gateway is used for this purpose.

  1. Define the ingress gateway for the application:

$ kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml

  1. Confirm the gateway has been created:
1
2
3
$ kubectl get gateway
NAME               AGE
bookinfo-gateway   32s
  1. Follow these instructions to set the INGRESS_HOST and INGRESS_PORT variables for accessing the gateway. Return here, when they are set.

  2. Set GATEWAY_URL:

$ export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT

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:

1
2
$ curl -s http://${GATEWAY_URL}/productpage | grep -o "<title>.*</title>"
<title>Simple Bookstore App</title>

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.

Apply default destination rules

Before you can use Istio to control the Bookinfo version routing, you need to define the available versions, called subsets, in destination rules.

Run the following command to create default destination rules for the Bookinfo services:

  • If you did not enable mutual TLS, execute this command:

    Choose this option if you are new to Istio and are using the demo configuration profile.

$ kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml

  • If you did enable mutual TLS, execute this command:

$ kubectl apply -f samples/bookinfo/networking/destination-rule-all-mtls.yaml

Wait a few seconds for the destination rules to propagate.

You can display the destination rules with the following command:

$ kubectl get destinationrules -o yaml

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 Tasks, depending on your interest. Configuring Request Routing 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 instructions:

  1. Delete the routing rules and terminate the application pods

$ samples/bookinfo/platform/kube/cleanup.sh

  1. Confirm shutdown
1
2
3
4
$ kubectl get virtualservices   #-- there should be no virtual services
$ kubectl get destinationrules  #-- there should be no destination rules
$ kubectl get gateway           #-- there should be no gateway
$ kubectl get pods              #-- the Bookinfo pods should be deleted