Kubernetes Introduction: Linkerd With Minikube

Joseph Eshiett
FAUN — Developer Community 🐾
8 min readNov 18, 2021

--

“Similar to Istio and other service mesh technologies, Linkerd is an application that also implements the Service Mesh paradigm or pattern in Kubernetes.”

For this article, we will not be going in-depth on what a Service Mesh is, as this was discussed already and in-depth in this Service Mesh article. Check it out.

Linkerd is a service mesh that adds observability, reliability, and security to Kubernetes applications without the need to make changes to code. For example, Linkerd can monitor and report per-service success rates and latencies, can also automatically retry failed requests, and can encrypt and validate connections between services, all without requiring any modification of the application itself.

Below is the Linkerd architecture :

Linkerd architecture

Following the service mesh pattern or paradigm, Linkerd has two main components:

Control plane:

This plane contains services such as Destination (used by proxies in the data plane to look up where to send and receive requests), Controller (creates an API for Linkerd command utility to communicate or interface with), Proxy-injector (as the name implies it injects Linkerd-proxy to each service instance as configured in the manifest file), Service profile validator. These services perform one function or the other in order to achieve observability, reliability and security in the cluster.

Data plane :

This plane contains sidecars otherwise called Linkerd-proxies which are deployed together with each service instance in pods.

If you wish to know more about the Linkerd architecture, you can check that out through this link.

Now before we get our hands dirty with Linkerd, let’s get to understand some terminologies.

Requirements for this hands-on demo:

  • Minikube (Check out the link to install )
  • Docker (Check out the link install )
  • Kubectl (Check out the link to install )

The above applications are required in order to work with Linkerd. If you don’t have any of the applications on your local machine you can check out the links above and follow the tutorials and get everything installed.

Now what are these applications exactly and what are they used for? Let’s address that:

What is Docker?

“Docker is basically an open source platform used to containerize applications.”

What is Minikube?

“This is a tool that let’s users run kubernetes on their local machines. Minikube runs a single-node kubernetes cluster on your personal computer, in order to perform development related work.”

This creates a VM on your local machine and runs docker containers inside of that virtual machine. Those docker containers are contained inside of the smallest execution unit in kubernetes called “pods”.

What is kubectl?

“This is the kubernetes command-line tool which allows users to run commands such as deploying applications, inspecting and managing kubernetes clusters and their resources etc.”

Now you know what the aforementioned applications are and what they are used for, let’s get started with Linkerd (A Linux machine will be used for this hands-on demo).

  • First thing we need to do is to install the Linkerd Command Line Interface, so we can interface with Linkerd services. In order to do that we perform the following command below:
curl -sL run.linkerd.io/install | sh
Linkerd successfully downloaded
  • let’s go ahead and add linkerd CLI to our OS path by exporting as an environment variable with the following command:
export PATH=$PATH:/home/<system-username>/linkerd2/bin
  • Let’s also confirm if the linkerd CLI has been successfully installed in our local machine. We simply do that by performing the following command:
linkerd version

The output would be:

Client version: stable-2.11.0
Server version: unavailable

The Server version is currently unavailable because it has not yet been added to our kubernetes cluster.

  • Let’s go ahead and start up minikube with specific resources, with the following command:
minikube start --cpus 4 --memory 4096

we have successfully started a minikube instance with specified resources and Kubernetes running in a docker container.

Let’s go ahead and install Linkerd control plane into our kubernetes cluster (this cluster was created automatically when minikube was started). We do that by performing the following command:

Linkerd control plane successfully added to the cluster

The linkerd install command generates a Kubernetes manifest with all the core control plane resources (Destination, linkerd-proxy injector, Controller, Service profile validator, and Identity). Piping (|)this manifest into kubectl apply then instructs Kubernetes to add those resources to your cluster.

  • Let’s confirm if our linkerd control plane and its resources have been installed correctly. We do that by performing the following command:
linkerd check
Linkerd control plane and resources successfully installed.

The command above simply displays resources that have been installed correctly and also displays the components that are up and healthy. So far the status after checking the results of the installation is OK.

  • In order to work with Linkerd effectively, we will need to install extensions. The two extensions we will be using for this demo is “viz” and “bouyant-cloud” extension.

N/B : Both viz and bouyant-cloud can be installed side by side but it is not required.

First off, let's go ahead and install “viz”. viz, once installed will install the on-cluster metric stack. This monitoring platform “viz” is based on Prometheus and Grafana. With this, we can view our Linkerd dashboard.

linkerd viz install | kubectl apply -f -

The linkerd viz install command generates a Kubernetes manifest with all the viz resources then piping (|)this manifest into kubectl apply which then instructs Kubernetes to add those resources to your cluster.

viz successfully added to the cluster
  • Now that we have viz installed, we can then install “bouyant-cloud” (this is optional). This is used to connect to the hosted metric stack and also help monitor and manage Linkerd services.

To install bouyant-cloud we perform the following commands below:

curl -sL buoyant.cloud/install | sh
linkerd buoyant install | kubectl apply -f -
buoyant-cloud successfully installed!

With bouyant-cloud successfully installed, we can view on our Linkerd services such as control plane and data plane, etc. via a dashboard hosted on the cloud.

  • Let's go ahead and view our on-cluster metrics via the viz dashboard. We simply do that by performing the following command:
linkerd viz dashboard &
Linkerd on-cluster metrics running!

Finally, we can view our on-cluster metrics via viz. As you can see above.

  • Lets go ahead and install a demo application provided by Linkerd and get a feel of how Linkerd services work. This application is called emojivoto. It is a simple emoji voting application based on gRPC (remote procedure call) and HTTP calls which allow users to vote on their favorite emojis as we will see shortly.

To install this application we will do that with the following command:

curl -sL run.linkerd.io/emojivoto.yml | kubectl apply -f -
emojivoto app manifest successfully appied

with the curl -sL run.linkerd.io/emojivoto.yml command, we are able to access the emojivoto app’s manifest file. Contained inside of this manifest file are the emojivoto app’s configurations including the namespace configuration and the application’s resources. We now pipe the manifest file to kubectl apply and apply the manifest file's configurations to our kubernetes cluster and get them running in the cluster.

  • Let’s confirm if our pods in the emojivoto namespace are up and running. To do that we run the following command:
kubectl -n emojivoto get pods
emojivoto app currently running!

Our emojivoto applications’ services are up and running in their respective pods. At the moment only the services are running in each pod and the sidecars or linkerd-proxy proxies have not yet been injected, hence the reason for “1/1”.

  • Before we get to inject the proxies, let’s go ahead and view the application on our browser. In order to view our application on our browsers, we will need to forward the web-svc service to run locally on port 8080. In order to do that we perform the following command:
kubectl -n emojivoto port-forward svc/web-svc 8080:80
Emoji vote app currently accessible via localhost

(In James Gordon’s voice…)Lovely! lovely! lovely! finally, our application is up and running on localhost in port 8080. Although we are not done just yet with this demo, we need to inject the sidecars into each pod in our cluster.

  • In order to inject the sidecars into our pods, we perform the following command:
curl -sL run.linkerd.io/emojivoto.yml | linkerd inject - | kubectl apply -f -
linkerd-proxy proxies injected into pods in emojivoto namespace.

The command curl -sL run.linkerd.io/emojivoto.yml | linkerd inject - scans the emojivoto manifest file, skips the rest of the configurations in the manifest, and then injects linkerd-proxy proxies into each deployment in the pod. With the kubectl apply -f - command, the emojivoto configuration was re-applied in our cluster and the sidecars were successfully injected.

  • Let’s confirm if the sidecars have been successfully injected with the following command:
kubectl -n emojivoto get pods
pods running with sidecars injected in each

Now the sidecars have been successfully injected into each pod in our cluster.

  • Let's check if the proxies in the data plane are all running fine. We do that with the following command:
linkerd -n emojivoto check --proxy
Status check results are OK!

Everything seems to be running fine so far. You have successfully used Linkerd for the first time!

  • Lets go ahead and view our Linkerd dashboard:
emoji vote application running with a success rate of 96% +

The emoji vote application is currently running with a 96% + success rate. Now you have successfully used Linkerd for the first time.

There are problems that may arise when you get to use the emoji vote application which can be debugged and fixed with Linkerd, Here’s a link on how to fix those problems.

Now the rest is up to you to study more, learn more and apply more! I wish you the best on your journey. Cheers.

Thank you for taking the time to read this!

Please do leave a comment if you have any thoughts on the topic — I am open to learning and continuous improvement!

I can imagine how helpful this post has been, do leave a clap 👏 below a few times to show your support for the author!

You can connect with me via Twitter, and email.

Join FAUN: Website 💻|Podcast 🎙️|Twitter 🐦|Facebook 👥|Instagram 📷|Facebook Group 🗣️|Linkedin Group 💬| Slack 📱|Cloud Native News 📰|More.

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

--

--