In this article, you will learn how to set up Linkerd as a Kubernetes Service Mesh using a free Platform9 Kubernetes account.
Linkerd is a light-weight service mesh for Kubernetes. It adds observability, reliability, and security to Kubernetes applications without code changes. For example, Linkerd can monitor and report per-service success rates and latencies, can automatically retry failed requests, and can encrypt and validate connections between services, all without requiring any modification of the application itself.
Linkerd has three basic components: a UI, a data plane, and a control plane. You run Linkerd by:
- Installing the CLI on your local system
- Installing the control plane into your cluster
- Adding your services to Linkerd’s data plane
Once a service is running with Linkerd, you can use Linkerd’s UI to inspect and manipulate it.
In this step by step guide, we will walk you through a basic set up of Linkerd to get you up and running.
To get started, create your free Platform9 Kubernetes account by entering your email below, then select the ‘Deploy Now’ option. Once you have created and verified your account, follow the steps outlined below.
Step 1: Create your free account
Minimum Kubernetes version required is 1.13. This can be checked by running the command –
kubectl version --short
If you’ve already set up your (free) managed Platform9 Kubernetes account, you don’t have to worry about this.
Installing Linkerd as a Kubernetes Service Mesh
While installing Linkerd as a Kubernetes Service Mesh, you need to download the Linkerd CLI. This CLI interacts with Linkerd, including installing the control plane onto your Kubernetes cluster.
Here’s the command to run the CLI manually –
curl -sL https://run.linkerd.io/install | sh
You can also download a CLI directly from the Linkerd releases page if you want to install a specific version.
Add the Linkerd to your path and also consider adding it to your .bashrc file too.
If you are using Homebrew, the command to install it is as follows –
brew install linkerd
Once installed, you can verify the version of linkerd by running the command –
Validating Linkerd CLI Installation
To ensure that Linkerd’s CLI has been successfully installed and all the pre-requisites like namespace Linkerd not being present etc., run the following command –
linkerd check --pre
All the checks in the above command should complete successfully, before proceeding.
Fig 1. Validating Linkerd CLI Installation
Installing Linkerd’s Control plane
linkerd install | kubectl apply -f -
you can change configuration options like choosing a custom namespace for Linkerd Control plane by running the command –
linkerd install -l | kubectl apply -f -
linkerd install -l linkerdtest | kubectl apply -f -
To explore all the available options while installing, run the command –
linkerd install --help
Once the installation is complete, you can run the following command to verify if all the Linkerd components are running successfully.
Exploring Linkerd Dashboard
You can explore the Linkerd Dashboard by running the following command —
linkerd dashboard &
If you are running this command from a Linux machine and would like the dashboard to listen on a specific interface instead of localhost by default, run the following commmand –
linkerd dashboard --address &
This command sets up a port forward from your local system to the linkerd-web pod.
Here’s the simple command to install the Linkerd’s Control plane with all the default configuration.
NOTE: If you cannot access browser from the machine you are running the above linkerd command, you can make Linkerd dashboard listening on a specific interface IP instead of localhost by default, you’ll have to edit the enforced-host container argument and set it to an empty string. Detailed instructions are here under Tweaking Host Requirement Section.
Installing Demo Application
Install the emojivoto application in the corresponding namespace by running the command –
curl -sL https://run.linkerd.io/emojivoto.yml \ | kubectl apply -f -
You can take a look at this application by using a port forward for the web-svc service associated with the emojivoto application by running the command –
kubectl -n emojivoto port-forward svc/web-svc 8080:80
Then, access the application using – http://localhost:8080/
NOTE: If you cannot access browser from the machine you are running the above kubectl command, you can make use the –address switch so you can reach it from your local machine and access it via a browser. The complete command is
kubectl -n emojivoto port-forward svc/web-svc 8080:80 --address
You might notice that that some parts of emojivoto app are broken. this is intentional and you can debug it further by checking out this link.
Injecting Linkerd into the Demo Application
You can inject Linkerd into the newly deployed Demo application by running the command –
kubectl get -n emojivoto deploy -o yaml \ | linkerd inject - \ | kubectl apply -f -
The first part of the command gets all the manifests from the emojivoto namespace; second part injects it with linkerd related metadata and then reapplies the configuration.
There will be no downtime associated with this operation as it would be a rolling deploy.
You can check if the above operation was successful by running the following command –
linkerd -n emojivoto check --proxy
Demo app has an included load generator so you can observe the live metrics associated with the traffic flowing.
linkerd -n emojivoto stat deploy
There’s a Grafana instance that comes prebuilt that shows metrics collected by Prometheus such as latency, request volume and success rate.
Fig 2. Grafana Dashboard
In this blog, we walked through a tutorial on how to set up Linkerd as a Kubernetes Service Mesh. We hope you found this blog informative and engaging. For more reads like this one, visit our blog page or subscribe for up-to-date news, projects, and related content in real-time.
Check out our additional complete stack projects in our Github repos.
- How To Set Up OpenEBS on Kubernetes Using Platform9 - December 22, 2020
- How To Set Up Linkerd as a Kubernetes Service Mesh - December 22, 2020
- How To Set Up Rook To Manage Ceph Within Kubernetes - December 22, 2020