Linkerd

Linkerd is a service mesh for Kubernetes. It makes running services easier and safer by giving you runtime debugging, observability, reliability, and security—all without requiring any changes to your code.

Installation

Ensure you have access to the Kubernetes cluster and a functioning kubectl, if not, you could set up Kubernetes cluster on your local machine through Minikube, docker desktop, or kind, etc.

Install linked CLI

For Linux

Follow the instructions from the official site: https://linkerd.io/2.14/getting-started/

curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh

For Windows

Download the Windows execution file from Github: https://github.com/linkerd/linkerd2/releases/

No need to install, change the file name to linkerd and add it to the Path environment.

Check whether linked cli is running correctly by

linkerd version

 Install Linkerd control plane

Check if your cluster is ready for installing Linkerd.

linkerd check --pre

Install Linkerd’s Custom Resource Definitions (CRDs), it must be installed first.

linkerd install --crds | kubectl apply -f -

Install Linkerd control panel.

linkerd install | kubectl apply -f -

You may encounter some installation errors, for example, the one below, based on the error message, change the install command accordingly.

linkerd install --set proxyInit.runAsRoot=true | kubectl apply -f -

 Check whether the control plane is installed successfully, linkerd control plane will be deployed to your cluster, a couple of images will be pulled, so make sure you have a workable network.

linkerd check

Deploy Linkerd to your application

First, you need an application deployed in your cluster, you can use the emojivoto application in https://linkerd.io/2.14/getting-started/.

After the application is deployed, add Linkerd's data plane proxy to it.

kubectl get -n emojivoto deploy -o yaml  | linkerd inject - | kubectl apply -f -

After emojivoto is 'meshed', check the data plane

linkerd -n emojivoto check --proxy

Dashboard

Install Linkerd's dashboard extension

linkerd viz install | kubectl apply -f -

This is the official way to access the dashboard

linkerd viz dashboard &

While this doesn't work when I using Windows docker desktop Kubernetes, I got this error

 Looks like the normal way doesn't work, so let's inspect the web service

 kubectl get service web -n linkerd-viz -o yaml

And, got this, service type is ClusterIP and listening at port 8080 port

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"linkerd.io/created-by":"linkerd/helm stable-2.14.7","linkerd.io/inject":"enabled"},"labels":{"component":"web","linkerd.io/extension":"viz","namespace":"linkerd-viz"},"name":"web","namespace":"linkerd-viz"},"spec":{"ports":[{"name":"http","port":8084,"targetPort":8084},{"name":"admin-http","port":9994,"targetPort":9994}],"selector":{"component":"web","linkerd.io/extension":"viz"},"type":"ClusterIP"}}
    linkerd.io/created-by: linkerd/helm stable-2.14.7
    linkerd.io/inject: enabled
  creationTimestamp: "2023-12-29T05:06:38Z"
  labels:
    component: web
    linkerd.io/extension: viz
    namespace: linkerd-viz
  name: web
  namespace: linkerd-viz
  resourceVersion: "5396830"
  uid: ba0b70ec-89f3-4f9a-a407-492744f3f90b
spec:
  clusterIP: 10.106.135.240
  clusterIPs:
  - 10.106.135.240
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http
    port: 8084
    protocol: TCP
    targetPort: 8084
  - name: admin-http
    port: 9994
    protocol: TCP
    targetPort: 9994
  selector:
    component: web
    linkerd.io/extension: viz
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

Then we can do a workaround, expose the service outside the cluster

kubectl -n linkerd-viz port-forward svc/web 8084

Bingo!!!

 

posted @ 2023-12-29 17:42  TigerLu  阅读(32)  评论(0编辑  收藏  举报