The Guestbook app is a sample app for users to leave comments. It consists of a web front end, Redis master for storage, and a replicated set of Redis slaves. We will also integrate the app with Watson Tone Analyzer which detects the sentiment in users' comments and replies with emoticons.
Clone the Guestbook app into the
git clone -b kubecon2019 https://github.com/IBM/guestbook
Navigate into the app directory.
In Kubernetes, a sidecar is a utility container in the pod, and its purpose is to support the main container. For Istio to work, Envoy proxies must be deployed as sidecars to each pod of the deployment. There are two ways of injecting the Istio sidecar into a pod: manually using the istioctl CLI tool or automatically using the Istio sidecar injector. In this exercise, we will use the automatic sidecar injection provided by Istio.
Annotate the default namespace to enable automatic sidecar injection:
kubectl label namespace default istio-injection=enabled
Validate the namespace is annotated for automatic sidecar injection:
kubectl get namespace -L istio-injection
NAME STATUS AGE ISTIO-INJECTIONdefault Active 271d enabledistio-system Active 5d2h...
The Redis database is a service that you can use to persist the data of your app. The Redis database comes with a master and slave modules.
Create the Redis controllers and services for both the master and the slave.
kubectl create -f redis-master-deployment.yamlkubectl create -f redis-master-service.yamlkubectl create -f redis-slave-deployment.yamlkubectl create -f redis-slave-service.yaml
Verify that the Redis controllers for the master and the slave are created.
kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGEredis-master 1/1 1 1 2m16sredis-slave 2/2 2 2 2m15s
Verify that the Redis services for the master and the slave are created.
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEredis-master ClusterIP 172.21.85.39 <none> 6379/TCP 5dredis-slave ClusterIP 172.21.205.35 <none> 6379/TCP 5d
Verify that the Redis pods for the master and the slave are up and running.
kubectl get pods
NAME READY STATUS RESTARTS AGEredis-master-4sswq 2/2 Running 0 5dredis-slave-kj8jp 2/2 Running 0 5dredis-slave-nslps 2/2 Running 0 5d
Inject the Istio Envoy sidecar into the guestbook pods, and deploy the Guestbook app on to the Kubernetes cluster. Deploy both the v1 and v2 versions of the app:
kubectl apply -f ../v1/guestbook-deployment.yamlkubectl apply -f guestbook-deployment.yaml
These commands deploy the Guestbook app on to the Kubernetes cluster. Since we enabled automation sidecar injection, these pods will be also include an Envoy sidecar as they are started in the cluster. Here we have two versions of deployments, a new version (
v2) in the current directory, and a previous version (
v1) in a sibling directory. They will be used in future sections to showcase the Istio traffic routing capabilities.
Create the guestbook service.
kubectl create -f guestbook-service.yaml
Verify that the service was created.
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEguestbook LoadBalancer 172.21.36.181 188.8.131.52 80:32149/TCP 5d...
Verify that the pods are up and running.
kubectl get pods
NAME READY STATUS RESTARTS AGEguestbook-v1-98dd9c654-dz8dq 2/2 Running 0 30sguestbook-v1-98dd9c654-mgfv6 2/2 Running 0 30sguestbook-v1-98dd9c654-x8gxx 2/2 Running 0 30sguestbook-v2-8689f6c559-5ntgv 2/2 Running 0 28sguestbook-v2-8689f6c559-fpzb7 2/2 Running 0 28sguestbook-v2-8689f6c559-wqbnl 2/2 Running 0 28sredis-master-577bc6fbb-zh5v8 2/2 Running 0 4m47sredis-slave-7779c6f75b-bshvs 2/2 Running 0 4m46sredis-slave-7779c6f75b-nvsd6 2/2 Running 0 4m46s
Note that each guestbook pod has 2 containers in it. One is the guestbook container, and the other is the Envoy proxy sidecar.
Great! Your guestbook app is up and running. In the next exercise you will expose the Istio service mesh with the Ingress Gateway