Installing a demo application

To install the demo emojivoto application, follow these steps:

  1. Deploy the emojivoto application through its YAML file:
$ curl -Ls https://run.linkerd.io/emojivoto.yml | kubectl apply -f -
  1. Check the application's status:
$ kubectl -n emojivoto get deployments,services,pods
NAME READY UP-TO-DATE AVAILABLE AGE ---
emoji 1/1 1 1 64s ---
vote-bot 1/1 1 1 63s ---
voting 1/1 1 1 64s ---
web 1/1 1 1 64s ---

NAME TYPE CLUSTER-IP EXTERNAL-IP ---
emoji-svc ClusterIP None <none> ---
voting-svc ClusterIP None <none> ---
web-svc LoadBalancer 10.109.50.125 192.168.142.251 ---

--- PORT(S) AGE
--- 8080/TCP 64s
--- 8080/TCP 64s
--- 80:30593/TCP 63s

NAME READY STATUS RESTARTS AGE
emoji-58c9579849-ql2z9 1/1 Running 0 64s
vote-bot-774764fd7f-rcd47 1/1 Running 0 63s
voting-66d5cdc46d-mrmb7 1/1 Running 0 64s
web-7f8455487f-p8tvf 1/1 Running 0 64s

The emojivoto app web UI can be accessed in multiple ways. We will create a hostname and an Ingress rule to route the traffic.

  1. Create the emojivoto.linked.local entry in /etc/hosts:
$ export INGRESS_HOST=$(kubectl -n kube-system get service nginx-controller -o jsonpath='{.status.loadBalancer.ingress..ip}') ; echo $INGRESS_HOST
192.168.142.249

$ sudo sed -i '/emojivoto.linkerd.local/d' /etc/hosts


$ echo "$INGRESS_HOST emojivoto.linkerd.local" | sudo tee -a /etc/hosts
  1. Define the emojivoto Ingress routing rule to route traffic from the emojivoto.linkerd.local external host to the web-svc internal microservice at port 80:
# Script : 02-create-emojivoto-ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: emojivoto
annotations:
nginx.org/websocket-services: "web-svc"
ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header l5d-dst-override $service_name.$namespace.svc.cluster.local:80;
proxy_hide_header l5d-remote-ip;
proxy_hide_header l5d-server-id;
spec:
rules:
- host: emojivoto.linkerd.local
http:
paths:
- backend:
serviceName: web-svc
servicePort: 80
path: /
You can acceshttp://emojivoto.linkerd.local from your localhost virtual machine. To access emojivoto from your local browser, create an entry in your Windows/MacBook hosts file.
  1. Create an emojivoto Ingress rule:
$ kubectl -n emojivoto apply -f 02-create-emojivoto-ingress.yaml
ingress.extensions/emojivoto created

You can check Ingress access through using the curl -s -H "Host: emojivoto.linkerd.local" http://$INGRESS_HOST | grep -i title command.

  1. Access the emojivoto web UI by launching http://emojivoto.linkerd.local from your browser in the VM:

Explore the app by clicking on an emoji. By doing this, you will vote for it. If you click on the doughnut emoji (third on the top row), you will get a 404 error. This is intentional and will cause the success rate to be less than 100%. We will refer to this error again in next chapter, when we deal with Linkerd's reliability features.

  1. Now let's inject the Linkerd sidecar proxy into the emoji application:
$ kubectl get -n emojivoto deploy -o yaml | linkerd inject - | kubectl apply -f -
deployment "emoji" injected
deployment "vote-bot" injected
deployment "voting" injected
deployment "web" injected

deployment.extensions/emoji configured
deployment.extensions/vote-bot configured
deployment.extensions/voting configured
deployment.extensions/web configured

Using the preceding command, we generate the emojivoto application deployment artifacts and pipe them through linkerd inject to generate a Linkerd sidecar proxy for each pod. The complete YAML is then fed to the kubectl apply command.

  1. Now, let's check the deployment, services, and pods. Run the following command to check the deployments:
$ kubectl -n emojivoto get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
emoji 1 1 1 64s
vote-bot 1 1 1 63s
voting 1 1 1 64s
web 1 1 1 64s
  1. Next, we will check the pods:
$ kubectl -n emojivoto get pods
NAME READY STATUS RESTARTS AGE
emoji-58c9579849-ql2z9 2/2 Running 0 64s
vote-bot-774764fd7f-rcd47 2/2 Running 0 63s
voting-66d5cdc46d-mrmb7 2/2 Running 0 64s
web-7f8455487f-p8tvf 2/2 Running 0 64s
  1. Finally, we will check the services:
$ kubectl -n emojivoto get services
NAME TYPE CLUSTER-IP EXTERNAL-IP ---
emoji-svc ClusterIP None <none> ---
voting-svc ClusterIP None <none> ---
web-svc LoadBalancer 10.0.0.132 192.168.142.251 ---

--- PORT(S) AGE
--- 8080/TCP 64s
--- 8080/TCP 64s
--- 80:31443/TCP 63s

Notice the difference between the previous deployment and the sidecar proxies. Each pod has an additional container, which is a Linkerd proxy.

Now, let's deploy the booksapp application to explore the features of Linkerd's service mesh.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.93.210