Install Linkerd Service Mesh in RancherDesktop Cluster

Install Linkerd in RancherDesktop cluster

In this blog will demonstrate setting up Linkerd service mesh in RancherDesktop. Will be only focusing on how we can manually and automatically inject linkerd-proxy to each container as sidecar.

Pre-requsities:

  • Understanding on Kubernetes, Service Mesh bascis is required.
  • kubectl installed from kubernetes website.
  • optionally, helm CLI but not necessary.

Service mesh at a very high level,

  • When deploying applications in Kubernetes cluster as container we need to control network traffic to and fro from the container, etc.
  • Service mesh implementation like Istio, Linkerd, Consul, etc provides those feature at infrastcuture layer that can control service to service communications.

Install RancherDesktop

  • Download the RancherDesktop binary for windows and install it, follow the instruction in rancherdesktop.io. This is very easy.

image

  • RancherDesktop uses k3s Kubernetes distribution, developed and maintained by SUSE/Rancher.
  • RancherDesktop provides a single node cluster. Currently, multi-node support is not available.
  • RancherDesktop also has a Dashboard to view namespace, containers, etc.
Verify the RancherDesktop cluster
  • Launch the RancherDesktop cluster by clicking the icon.
  • It will take few minutes for the the cluster to be up and running, progress can be tracked in the GUI.

Note

  • The RancherDesktop will use the rancher-desktop context.
  • In case if you where using DockerDesktop, switch context to rancher-desktop using kubectl.
  • Create the first Pod in the cluster,
    • Open a command prompt and issue kubectl run pod1 --image=nginx
    • verify the status using kubectl get pods, the status of pod1 should be running.

Note

  • RancherDesktop GUI provides port forwarding option, if we create a service its easy to forward traffic to and from host laptop.
  • When setting up the Linkerd demo app will demonstrate port forwarding and how to access the application using port forward from local host laptop.

image

Install Linkerd Service Mesh

  • Download and Install the Linkerd CLI binary from linkerd website, Github release, extract this binary and place in a directory.
  • Add the executable path in the windows Environment path variable, so it will be recognized in command prompt or powershell.
Validate Linkerd CLI
  • If Linkerd CLI is installed correctly, open command prompt and issue linkerd version command this should display the version like in below snippet.

    Client version: stable-2.11.3
    Server version: stable-2.11.3
    

Install Linkerd service mesh in RancherDesktop cluster

  • Using the linkerd cli, we can generate the deployment yaml, and use kubectl command to install it in the cluster.
  • Details and steps are documented in the linkerd website, refer this link refence for more details.

    • We can use below command to install linkerd service mesh.
    • In this case we are piping the linkerd install output to kubectl directly.
    > linkerd install | kubectl apply -f -
    
  • Once installed, we see that resources running under the linkerd namespace

    image

  • To verify and check if everything is installed correctly use linkerd check command.

image

Inject Linkderd proxy - Automatic

  • By creating specific annotation at the namespace, we can configure linkerd control pane to manager the proxy injection automatic.
# Creating an emojivoto namespace used for linkerd demo application as well
> kubectl creaet namespace emojivoto

# create annotation on the emojivoto namespace
> kubectl annotation namespace emojivoto linkerd.io/inject=enabled
  • With the above configuration, if we issue kubectl run pod1 --image=nginx, it will create a container and we can notice the proxy injected automatically.
  • Use kubectl -n emojivoto get pods, notice the Pod Ready state indicating 2/2. We can describe the pod and see the proxy injected

image

image

Inject Linkerd proxy - manually

  • In order to manually inject, we need to use linkerd cli command.
  • Once we build the deployment descriptor yaml file, we need to pass the file to linkerd inject command
# use linkerd inject to mutated the custom deployment with linkerd proxy configuration
> cat mydeployment.yml | linkerd inject > deploymentwithproxy.yml

# deploy using kubectl
> kubectl apply -f deploymentwithproxy.yml

Install linkerd emojivoto demo app

  • Download the deployment descriptor yaml, using below command
> curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/emojivoto.yml > emojoapp.yml
  • Use kubectl apply command to install the resources to cluster
> kubectl apply -f emojoapp.yml
  • Use kubectl -n emojivoto get pods to view the deployed resources

image

Accessing the demo application from localhost

  • Open up the RancherDesktop, enable the port forwarding for the service created by the linkerd demo app.

  • In the below image, port forwarding is enabled for all the service created by the demo app.

image

  • Now we can use the port displayed for the accessing the application, the web-svc service is where we need to start.
  • In my case http://localhost:62173.

image

Install Linkerd dashboard

  • We need to install the linkerd viz to the cluster using below command
> linkerd viz install | kubectl apply -f -

# use below command to check if everything is setup correctly
>linkerd check
Monitor traffic in linkerd dashboard
  • With the below command we can start the linkerd dashboard
> linkerd viz dashboard
  • Issuing above command, will open up the the dashboard in the browser automatically
  • Below image depicts the list of namespace and pods, etc displayed in the daskboard.

image

image

  • Clicking the Grafana icon near the pod will bring up the Grafana dashboard with visualization of pod traffic and other Observability metrics.

image

Bonus - using nerdctl cli

  • In RancherDesktop, I was using Containerd Container Runtime, in order to manage images for containerd we can use nerdctl cli.
  • First install the nerdclt CLI for windows from containerd Github
  • Note, nerdctl command is similar to Docker CLI command, all options are supported there, refer documentation.
  • With the nerdctl command, we can build the image and directly deploy to RancherDesktop cluster, no need to push to dockerhub.
  • Refer RancherDesktop reference working on images using nerdctl
  • Below lists the image built for a simple GoLang app, using using nerdctl cli
C:\go_k8s>nerdctl --namespace k8s.io images
REPOSITORY                    TAG           IMAGE ID        CREATED           PLATFORM       SIZE         BLOB SIZE
thiru/mygoapp            v1.0         ab83037c8160    57 seconds ago    linux/amd64    7.6 MiB      3.7 MiB
  • Command to deploy the image created in the local repo directly deploy in RancherDesktop cluster
C:\go_k8s>kubectl run goapp --image thiru/mygoapp:v1.0
pod/goapp created