Overview

Although Linkerd has heard of its name for a long time, and probably understand some of its architecture, but really have not tried it, mainly because its previous version is really not easy to use, but it is said that the second version has changed a lot, so recently followed the video of others to play a little, by the way, a water.

Environment preparation

Install Kind

The environment used is Ubuntu.

  1. [[email protected].io]# curl -Lo . /kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
  2. [[email protected].io]# chmod +x . /kind
  3. [[email protected].io]# mv . /kind /usr/local/bin/kind

Creating a cluster

  1. [[email protected].io]# kind create cluster
  2. [[email protected].io]# kind create cluster --name linkerd --image kindest/node:v1.19.1
  3. [[email protected].io]# kind get clusters
  4. kind
  5. linkerd

Add local DNS records

  1. [[email protected].io]# sudo echo "127.0.0.1 servicemesh.demo" >> /etc/hosts

Deploying a test application

  1. [[email protected].io]# git clone https://github.com/marcel-dempers/docker-development-youtube-series.git
  2. [[email protected].io]# echo "create nginx ingress"
  3. [[email protected].io]# kubectl create ns ingress-nginx
  4. [[email protected].io]# kubectl apply -f kubernetes/servicemesh/applications/ingress-nginx/
  5. [[email protected].io]# echo "create applications"
  6. [[email protected].io]# kubectl apply -f kubernetes/servicemesh/applications/playlists-api/
  7. [[email protected].io]# kubectl apply -f kubernetes/servicemesh/applications/playlists-db/
  8. [[email protected].io]# kubectl apply -f kubernetes/servicemesh/applications/videos-web/
  9. [[email protected].io]# kubectl apply -f kubernetes/servicemesh/applications/videos-api/
  10. [[email protected].io]# kubectl apply -f kubernetes/servicemesh/applications/videos-db/

To access the test application, open a local browser and type: http://servicemesh.demo/home/ and you should see this page.

Figure 0: Test app page

Deploying Linkerd

Here I followed someone else’s video action and chose a Docker container to operate within.

  1. [[email protected].io]# docker run -it --rm -v ${HOME}:/root/ -v ${PWD}:/work -w /work --net host alpine:3.12 sh
  2. /work # echo "Now inside the container"
  3. /work # apk add --no-cache curl nano
  4. /work # curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/ release/stable.txt `/bin/linux/amd64/kubectl
  5. /work # chmod +x . /kubectl
  6. /work # mv . /kubectl /usr/local/bin/kubectl
  7. /work # export KUBE_EDITOR="nano"
  8. /work # kubectl get nodes
  9. NAME STATUS ROLES AGE VERSION
  10. linkerd-control-plane Ready master 127m v1.19.1

Install Linkerd Cli.

  1. /work # curl -L -o linkerd https://github.com/linkerd/linkerd2/releases/download/edge-20.10.1/linkerd2-cli-edge-20.10.1-linux-amd64
  2. /work # chmod +x linkerd && mv . /linkerd /usr/local/bin/
  3. /work # linkerd check --pre

You should see a piece of ✅ right at the end, with a little Warning, and the result here is ❎, because I executed it after installation, so please ignore it:

Figure 1: Precheck

Installing Linkerd

  1. [[email protected].io]# linkerd install > . /kubernetes/servicemesh/linkerd/manifest/linkerd-edge-20.10.1.yaml
  2. [[email protected].io]# kubectl apply -f . /kubernetes/servicemesh/linkerd/manifest/linkerd-edge-20.10.1.yaml
  3. [[email protected].io]# linkerd check

Check again, it should be working at this point.

Figure 2: PostCheck

View Dashboard

  1. [[email protected].io]# kubectl -n linkerd port-forward svc/linkerd-web 8084

If you’re on a remote machine, you may need to proxy a bit (if you can’t be bothered) because Linkerd has set up Host filtering:

  1. [[email protected].io]# ssh -L 8084:127.0.0.1:8084 <host-ip>

Then visit http://127.0.0.1:8084/namespaces and you will see this screen.

Figure 3: Linkerd Dashboard

The following is a formal injection of Linkerd, which is the same as Istio, and is achieved by injecting Sidecar, so there is no difference.

Linkerd uses

to inject Sidecar

In this step, we start injecting Linkerd’s sidecar into all the services, and then we’ll see what’s displayed in the Dashboard, if we don’t inject Sidecar, nothing will be displayed:

  1. [[email protected].io]# kubectl get deploy playlists-api -o yaml | linkerd inject - | kubectl apply -f -
  2. [[email protected].io]# kubectl get deploy playlists-db -o yaml | linkerd inject - | kubectl apply -f -
  3. [[email protected].io]# kubectl get deploy videos-api -o yaml | linkerd inject - | kubectl apply -f -
  4. [[email protected].io]# kubectl get deploy videos-db -o yaml | linkerd inject - | kubectl apply -f -
  5. [[email protected].io]# kubectl get deploy videos-web -o yaml | linkerd inject - | kubectl apply -f -
  6. [[email protected].io]# kubectl -n ingress-nginx get deploy nginx-ingress-controller -o yaml | linkerd inject - | kubectl apply -f -

Then open Dashboard:

Figure 4:Dashboard Data

You can see that the Meshed Pods have some success rate and latency data, which means Sidecar is working. The Dashboard doesn’t really have much to offer, but after clicking on a Metric you can see a graph of the call chain, and not much else.

Figure 5: Call chain
!

Monitoring traffic

This Dashboard is used to monitor traffic. For example, after you find an API exception, you can use this monitoring dashboard to see the status of the API to locate and resolve the exception:

Figure 6: Traffic Monitoring

Summary

That’s about it for this article, but it’s mostly a reference to this video (Introduction to Linkerd for beginners | a Service Mesh). I’ve learned how to use Linkerd, but I haven’t had a chance to experience some of the features, so I’ll continue.