Linkerd Patterns

Linkerd Patterns

Teaches Linkerd service mesh patterns on Kubernetes: automatic mTLS, traffic splits for canaries, service profiles, retries, timeouts and multi-cluster setups.

Skill files1 file
SKILL.md310 lines
1
---
2
name: linkerd-patterns
3
description: Implement Linkerd service mesh patterns for lightweight, security-focused service mesh deployments. Use when setting up Linkerd, configuring traffic policies, or implementing zero-trust networking with minimal overhead.
4
---
5
6
# Linkerd Patterns
7
8
Production patterns for Linkerd service mesh - the lightweight, security-first service mesh for Kubernetes.
9
10
## When to Use This Skill
11
12
- Setting up a lightweight service mesh
13
- Implementing automatic mTLS
14
- Configuring traffic splits for canary deployments
15
- Setting up service profiles for per-route metrics
16
- Implementing retries and timeouts
17
- Multi-cluster service mesh
18
19
## Core Concepts
20
21
### 1. Linkerd Architecture
22
23
```
24
┌─────────────────────────────────────────────┐
25
│ Control Plane │
26
│ ┌─────────┐ ┌──────────┐ ┌──────────────┐ │
27
│ │ destiny │ │ identity │ │ proxy-inject │ │
28
│ └─────────┘ └──────────┘ └──────────────┘ │
29
└─────────────────────────────────────────────┘
30
│
31
┌─────────────────────────────────────────────┐
32
│ Data Plane │
33
│ ┌─────┐ ┌─────┐ ┌─────┐ │
34
│ │proxy│────│proxy│────│proxy│ │
35
│ └─────┘ └─────┘ └─────┘ │
36
│ │ │ │ │
37
│ ┌──┴──┐ ┌──┴──┐ ┌──┴──┐ │
38
│ │ app │ │ app │ │ app │ │
39
│ └─────┘ └─────┘ └─────┘ │
40
└─────────────────────────────────────────────┘
41
```
42
43
### 2. Key Resources
44
45
| Resource | Purpose |
46
| ----------------------- | ------------------------------------ |
47
| **ServiceProfile** | Per-route metrics, retries, timeouts |
48
| **TrafficSplit** | Canary deployments, A/B testing |
49
| **Server** | Define server-side policies |
50
| **ServerAuthorization** | Access control policies |
51
52
## Templates
53
54
### Template 1: Mesh Installation
55
56
Use a CLI version compatible with the target cluster. The example uses Homebrew;
57
for other systems, follow the [official installation guide](https://linkerd.io/docs/getting-started/).
58
59
```bash
60
# Install the CLI with Homebrew
61
brew install linkerd
62
linkerd version
63
64
# Validate cluster
65
linkerd check --pre
66
67
# Install CRDs
68
linkerd install --crds | kubectl apply -f -
69
70
# Install control plane
71
linkerd install | kubectl apply -f -
72
73
# Verify installation
74
linkerd check
75
76
# Install viz extension (optional)
77
linkerd viz install | kubectl apply -f -
78
```
79
80
### Template 2: Inject Namespace
81
82
```yaml
83
# Automatic injection for namespace
84
apiVersion: v1
85
kind: Namespace
86
metadata:
87
name: my-app
88
annotations:
89
linkerd.io/inject: enabled
90
---
91
# Or inject specific deployment
92
apiVersion: apps/v1
93
kind: Deployment
94
metadata:
95
name: my-app
96
annotations:
97
linkerd.io/inject: enabled
98
spec:
99
template:
100
metadata:
101
annotations:
102
linkerd.io/inject: enabled
103
```
104
105
### Template 3: Service Profile with Retries
106
107
```yaml
108
apiVersion: linkerd.io/v1alpha2
109
kind: ServiceProfile
110
metadata:
111
name: my-service.my-namespace.svc.cluster.local
112
namespace: my-namespace
113
spec:
114
routes:
115
- name: GET /api/users
116
condition:
117
method: GET
118
pathRegex: /api/users
119
responseClasses:
120
- condition:
121
status:
122
min: 500
123
max: 599
124
isFailure: true
125
isRetryable: true
126
- name: POST /api/users
127
condition:
128
method: POST
129
pathRegex: /api/users
130
# POST not retryable by default
131
isRetryable: false
132
- name: GET /api/users/{id}
133
condition:
134
method: GET
135
pathRegex: /api/users/[^/]+
136
timeout: 5s
137
isRetryable: true
138
retryBudget:
139
retryRatio: 0.2
140
minRetriesPerSecond: 10
141
ttl: 10s
142
```
143
144
### Template 4: Traffic Split (Canary)
145
146
```yaml
147
apiVersion: split.smi-spec.io/v1alpha1
148
kind: TrafficSplit
149
metadata:
150
name: my-service-canary
151
namespace: my-namespace
152
spec:
153
service: my-service
154
backends:
155
- service: my-service-stable
156
weight: 900m # 90%
157
- service: my-service-canary
158
weight: 100m # 10%
159
```
160
161
### Template 5: Server Authorization Policy
162
163
```yaml
164
# Define the server
165
apiVersion: policy.linkerd.io/v1beta1
166
kind: Server
167
metadata:
168
name: my-service-http
169
namespace: my-namespace
170
spec:
171
podSelector:
172
matchLabels:
173
app: my-service
174
port: http
175
proxyProtocol: HTTP/1
176
---
177
# Allow traffic from specific clients
178
apiVersion: policy.linkerd.io/v1beta1
179
kind: ServerAuthorization
180
metadata:
181
name: allow-frontend
182
namespace: my-namespace
183
spec:
184
server:
185
name: my-service-http
186
client:
187
meshTLS:
188
serviceAccounts:
189
- name: frontend
190
namespace: my-namespace
191
---
192
# Allow unauthenticated traffic (e.g., from ingress)
193
apiVersion: policy.linkerd.io/v1beta1
194
kind: ServerAuthorization
195
metadata:
196
name: allow-ingress
197
namespace: my-namespace
198
spec:
199
server:
200
name: my-service-http
201
client:
202
unauthenticated: true
203
networks:
204
- cidr: 10.0.0.0/8
205
```
206
207
### Template 6: HTTPRoute for Advanced Routing
208
209
```yaml
210
apiVersion: policy.linkerd.io/v1beta2
211
kind: HTTPRoute
212
metadata:
213
name: my-route
214
namespace: my-namespace
215
spec:
216
parentRefs:
217
- name: my-service
218
kind: Service
219
group: core
220
port: 8080
221
rules:
222
- matches:
223
- path:
224
type: PathPrefix
225
value: /api/v2
226
- headers:
227
- name: x-api-version
228
value: v2
229
backendRefs:
230
- name: my-service-v2
231
port: 8080
232
- matches:
233
- path:
234
type: PathPrefix
235
value: /api
236
backendRefs:
237
- name: my-service-v1
238
port: 8080
239
```
240
241
### Template 7: Multi-cluster Setup
242
243
```bash
244
# On each cluster, install with cluster credentials
245
linkerd multicluster install | kubectl apply -f -
246
247
# Link clusters
248
linkerd multicluster link --cluster-name west \
249
--api-server-address https://west.example.com:6443 \
250
| kubectl apply -f -
251
252
# Export a service to other clusters
253
kubectl label svc/my-service mirror.linkerd.io/exported=true
254
255
# Verify cross-cluster connectivity
256
linkerd multicluster check
257
linkerd multicluster gateways
258
```
259
260
## Monitoring Commands
261
262
```bash
263
# Live traffic view
264
linkerd viz top deploy/my-app
265
266
# Per-route metrics
267
linkerd viz routes deploy/my-app
268
269
# Check proxy status
270
linkerd viz stat deploy -n my-namespace
271
272
# View service dependencies
273
linkerd viz edges deploy -n my-namespace
274
275
# Dashboard
276
linkerd viz dashboard
277
```
278
279
## Debugging
280
281
```bash
282
# Check injection status
283
linkerd check --proxy -n my-namespace
284
285
# View proxy logs
286
kubectl logs deploy/my-app -c linkerd-proxy
287
288
# Debug identity/TLS
289
linkerd identity -n my-namespace
290
291
# Tap traffic (live)
292
linkerd viz tap deploy/my-app --to deploy/my-backend
293
```
294
295
## Best Practices
296
297
### Do's
298
299
- **Enable mTLS everywhere** - It's automatic with Linkerd
300
- **Use ServiceProfiles** - Get per-route metrics and retries
301
- **Set retry budgets** - Prevent retry storms
302
- **Monitor golden metrics** - Success rate, latency, throughput
303
304
### Don'ts
305
306
- **Don't skip check** - Always run `linkerd check` after changes
307
- **Don't over-configure** - Linkerd defaults are sensible
308
- **Don't ignore ServiceProfiles** - They unlock advanced features
309
- **Don't forget timeouts** - Set appropriate values per route
310

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…