🔗
Container Platform

Linkerd

Lightweight Kubernetes service mesh — mTLS, metrics, retries

🐧 Linux🍎 Mac🪟 Windows
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

Linkerd is a lightweight service mesh that adds mTLS, metrics, and retries between pods.

📥

Step 01

Install Linkerd

(01)Install Linkerd

Linux
1curl -fsL https://run.linkerd.io/install | sh
2export PATH=$PATH:$HOME/.linkerd2/bin
3linkerd version
⚙️

Step 02

Configure Linkerd

(01)Configure Linkerd

Linux
1linkerd install | kubectl apply -f -
2linkerd viz install | kubectl apply -f -
3kubectl annotate namespace default linkerd.io/inject=enabled
4linkerd check

Step 03

Verify

(01)Verify installation

Linux
1linkerd viz dashboard &
2linkerd stat deploy -n default
🔧

Step 04

Common Problems

#1linkerd check fails / proxy not injected

Linux
1linkerd check
2kubectl get pods -n linkerd
3kubectl annotate namespace default linkerd.io/inject=enabled --overwrite
4kubectl rollout restart deployment

📋Config templates

2 YAML templates for Linkerd. Copy and deploy after setup.

2 ready-to-copy templates. Expand one, copy the YAML, then run the deploy commands.

configmap.yml

yaml
1apiVersion: v1
2kind: ConfigMap
3metadata:
4 name: node-api-config
5data:
6 NODE_ENV: "production"
7 WORKER_URL: "http://worker-svc:4000"

gateway-deployment.yml

yaml
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: gateway
5spec:
6 replicas: 2
7 selector:
8 matchLabels:
9 app: gateway
10 template:
11 metadata:
12 labels:
13 app: gateway
14 spec:
15 containers:
16 - name: gateway
17 image: node-gateway:local
18 imagePullPolicy: IfNotPresent
19 ports:
20 - containerPort: 3000
21 envFrom:
22 - configMapRef:
23 name: node-api-config
24 resources:
25 requests:
26 memory: "128Mi"
27 cpu: "100m"
28 limits:
29 memory: "256Mi"
30 cpu: "250m"

gateway-svc.yml

yaml
1apiVersion: v1
2kind: Service
3metadata:
4 name: gateway-svc
5spec:
6 type: NodePort
7 selector:
8 app: gateway
9 ports:
10 - port: 3000
11 targetPort: 3000
12 nodePort: 32300

worker-deployment.yml

yaml
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: worker
5spec:
6 replicas: 1
7 selector:
8 matchLabels:
9 app: worker
10 template:
11 metadata:
12 labels:
13 app: worker
14 spec:
15 containers:
16 - name: worker
17 image: node-worker:local
18 imagePullPolicy: IfNotPresent
19 ports:
20 - containerPort: 4000
21 resources:
22 requests:
23 memory: "128Mi"
24 cpu: "100m"

worker-svc.yml

yaml
1apiVersion: v1
2kind: Service
3metadata:
4 name: worker-svc
5spec:
6 type: ClusterIP
7 selector:
8 app: worker
9 ports:
10 - port: 4000
11 targetPort: 4000
📄

Step 01

Deploy Node Microservices

(01)Build and load images

Linux
1docker build -t node-gateway:local ./gateway
2docker build -t node-worker:local ./worker
3minikube image load node-gateway:local
4minikube image load node-worker:local

(02)Apply manifests

Linux
1kubectl apply -f configmap.yml
2kubectl apply -f gateway-deployment.yml
3kubectl apply -f gateway-svc.yml
4kubectl apply -f worker-deployment.yml
5kubectl apply -f worker-svc.yml
6kubectl get pods,svc