AlgoViz

Linkerd

medium 26 min

Linkerd is a service mesh for Kubernetes that aims to be small.

Video lesson · Chapter 1 of 5

Give a parcel service a verifiable sender

0:00 / 4:18

Linkerd in 90 seconds

1:30Reel coming soon

Theory

Read or listen first. About 2 min.

What it is

Linkerd (say "linker-dee") is a service mesh: proxies on the path of every call, and a control plane that tells them where to send it and who may call whom. It is open source under the Apache License 2.0 and a graduated project of the Cloud Native Computing Foundation.

Its data plane is a micro-proxy written in Rust for this one job, placed as a sidecar in each pod. Its control plane has three main parts: the destination service, the identity service and the proxy injector.

It works with no configuration for the basics: add an annotation, restart the pods, and traffic between meshed pods is encrypted, balanced and measured.

Why it exists

Calls between microservices fail and slow down in ways nobody sees. The first need is usually plain: how many requests, how many fail, how slow, and from whom? The second is encryption with identity.

A general mesh such as Istio can do more and asks for more. Linkerd leaves features out on purpose, so that a small team can run it.

A short history

  1. 2016

    Buoyant creates Linkerd, the first service mesh project. It joins the CNCF in January 2017.

  2. September 2018

    Linkerd 2.0, a complete rewrite: a Rust proxy and a control plane in Go, for Kubernetes.

  3. July 2021

    Linkerd becomes the first service mesh to graduate in the CNCF.

  4. February 2024

    With 2.15 the open source project stops publishing stable releases. Edge releases continue; stable ones come from vendors.

  5. June 2026

    Linkerd 2.20: balancing that reacts to rate limit answers, native sidecars as the default, and a smaller control plane.

Words to know

Meshed pod
A pod that has the Linkerd proxy.
Outbound proxy
The caller's side: discovery, balancing, retries, timeouts, circuit breaking.
Inbound proxy
The called side: checks authorization, limits rates.
EWMA
Exponentially weighted moving average, here of an endpoint's latency.
Trust anchor
The root certificate that all proxies trust.
Issuer certificate
The intermediate certificate with which the control plane signs proxy certificates.
Opaque port
A port whose traffic is passed on as plain TCP, without looking for HTTP.
Golden metrics
Success rate, requests per second, and latency.
Edge release
The project's own build, published about every week.

How it works

Step through the idea, or press Play.

Step 1 of 3

Inject. An annotation adds the proxy to the pod

Understand it

Start here

A small bell on every door

Imagine a street with three workshops. Customers come and go, and nobody knows how many, how long they wait, or who they are. What is the smallest thing you could add to each door?

Light bells that count
1?2?3?Who came, and how often?

A bell is not a doorkeeper with a rule book. It is light, and that is the point.

The idea

What you get, and when

FeatureWithout configurationSwitched on by
mTLS between meshed podsYesNothing
Golden metricsYesNothing; the Viz extension shows them
Balancing per request by latencyYesNothing
Retries and timeoutsNoAnnotations on a Service or route
Circuit breakingNoAnnotations on a Service
Traffic split and header routesNoHTTPRoute, GRPCRoute
Access rulesNo: all is allowedPolicy resources, default policy
Local rate limitsNoHTTPLocalRateLimitPolicy
  • Small proxy

    Rust, made only to be a mesh sidecar. Memory safety removes a class of bugs.

  • On by default

    Encryption and metrics need no rules, so they are not forgotten.

  • Latency-aware

    Requests move away from slow pods within moments.

  • Kubernetes style

    Gateway API routes, annotations, service accounts.

  • Fewer knobs

    Less to learn, and less that can be set wrongly.

  • Clusters joined

    Services of another cluster appear as local ones.

The ideas have their own pages: circuit breaker, retries, timeouts, service discovery, monitoring. Here we see how this product does them on Kubernetes.

Inside

Three parts and many proxies

Control plane and data plane

A cluster with a control plane of three parts: destination, identity and injector. Pod web holds an application and an outbound proxy; pod orders holds an inbound proxy and an application. Calls go from web through its proxy over mutual TLS to the proxy of orders. Dashed arrows show addresses and certificates coming from the control plane.
The control plane runs on the mesh too, so its own traffic is encrypted.

The control plane

PartAnswers the question
DestinationWhere are the endpoints, which identity must they show, and which policies and routes apply?
IdentityIs this proxy who it says? Then here is its certificate
Proxy injectorDoes this new pod carry the annotation? Then add the proxy

A pod joins the mesh

An init container, or the CNI plugin, redirects the pod's TCP traffic with iptables. The key never leaves the pod.

Since 2.20 the proxy is a native sidecar by default. Kubernetes starts it before the application and stops it after, which solves two old problems: calls that failed at start because the proxy was not ready, and jobs that never ended because the proxy ran on.

Request

Who does what on one call

web calls orders

Outbound (caller)Inbound (called)
Finds endpointsChecks authorization
Balances each requestLimits the rate, per pod
Retries, timeouts, circuit breakingPasses to the app
CountsCounts
So a caller outside the mesh gets no retries, no breaker and no latency-aware balancing, wherever you put the annotations.

Balancing

Send it where it is quick now

Kubernetes balances connections. HTTP/2 and gRPC keep one connection open, so all requests of a client end up on one pod. Linkerd balances requests, over all endpoints of the Service, and prefers those with a low moving average of latency.

The moving average

enew=α⋅x+(1−α)⋅eold0.2×500+0.8×20=116 mse_{new} = \alpha \cdot x + (1 - \alpha) \cdot e_{old} \qquad 0.2 \times 500 + 0.8 \times 20 = 116\ \text{ms}
One answer of 500 ms moves an endpoint from 20 to 116 ms with a weight of 0.2 (our example value). Newer answers count more, so it reacts and recovers.

Two limits. For plain TCP it can only balance connections. And calls to a pod address, or to a headless Service, are not balanced, because the caller has already chosen the pod. With 2.20 the balancer can also turn away from endpoints that answer 429 or RESOURCE_EXHAUSTED.

Resilience

Retries, timeouts, breakers

YAML
apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:  name: ratings-read  namespace: shop  annotations:    retry.linkerd.io/http: gateway-error      # 502, 503, 504    retry.linkerd.io/limit: "1"    retry.linkerd.io/timeout: 300ms    timeout.linkerd.io/request: 1sspec:  parentRefs:    - kind: Service      group: ""      name: ratings      port: 80  rules:    - matches:        - method: GET          path: {type: PathPrefix, value: /ratings}---apiVersion: v1kind: Servicemetadata:  name: ratings  namespace: shop  annotations:    balancer.linkerd.io/failure-accrual: consecutivespec:  selector: {app: ratings}  ports:    - {port: 80, targetPort: 8080, appProtocol: http}
Only GET is retried here. A route's annotations replace those of the Service.

Defaults, once switched on

SettingDefault
Retries per request1
Bodies that can be retriedUp to 64 KiB
Request timeoutNone; when reached it is final, not retried
Retry timeoutNone; when reached the try is cancelled and repeated
Failures in a row before a break7
First penalty, longest penalty1 second, 1 minute
Jitter on penaltiesRatio 0.5
From the reference, November 2026. If a ServiceProfile exists for the Service, these annotations are ignored.

One endpoint's breaker

A passed health check does not end the break. Only a real request does.

If all endpoints are out, requests fail with 503, or another backend of the route is used. The second policy, unified, also breaks when the success rate falls below 80% in 10 seconds and at least 5 answers came; those settings still carry alpha names.

Why failures in a row can miss a sick pod

p=13:p7=12187,1−p7(1−p) p7≈3279 requestsp = \tfrac{1}{3}: \quad p^{7} = \tfrac{1}{2187}, \qquad \frac{1 - p^{7}}{(1 - p)\,p^{7}} \approx 3279\ \text{requests}
If a third of the calls fail at random, it takes about 3,279 requests on average until seven fail in a row. The success-rate rule sees 67%, below 80%, within its 10 second window.

Security

mTLS on, policy off

  1. 1

    Trust anchor

    The root. The one made by a default install ends after 365 days, and replacing it by hand takes care.

  2. 2

    Issuer

    Signed by the anchor, kept as a Kubernetes Secret that only identity can read. Also one year by default.

  3. 3

    Proxy certificate

    Bound to the pod's service account, 24 hours, renewed by the proxy.

  4. 4

    Handshake

    TLS 1.3 with a hybrid post-quantum key exchange, ML-KEM-768 with X25519.

By default the policy is all-unauthenticated: meshed traffic is encrypted, and plain text from outside the mesh is still accepted. Stricter defaults are all-authenticated, cluster-authenticated and deny. The audit mode allows and logs what would be refused: use it first.

YAML
apiVersion: policy.linkerd.io/v1beta3kind: Servermetadata:  name: orders-http  namespace: shopspec:  podSelector:    matchLabels: {app: orders}  port: http  proxyProtocol: HTTP/1  accessPolicy: audit          # later: deny---apiVersion: policy.linkerd.io/v1alpha1kind: MeshTLSAuthenticationmetadata:  name: web  namespace: shopspec:  identityRefs:    - kind: ServiceAccount      name: web---apiVersion: policy.linkerd.io/v1alpha1kind: AuthorizationPolicymetadata:  name: orders-from-web  namespace: shopspec:  targetRef:    group: policy.linkerd.io    kind: Server    name: orders-http  requiredAuthenticationRefs:    - group: policy.linkerd.io      kind: MeshTLSAuthentication      name: web
A Server without an accessPolicy denies what no rule allows. Refused HTTP gets 403; other traffic is refused as a connection.

Probes are allowed automatically as long as no route is attached to the Server; then you must allow them yourself. Pods that skip the proxy are not protected: high availability mode refuses to start annotated pods without it.

Protocols

HTTP, TCP and the ten seconds

The proxy looks at the first bytes to see whether a connection is HTTP. If it is not, or if the application already uses TLS, it passes the bytes on as TCP: still mTLS between proxies, but no requests, routes or retries.

What is this connection?

Protocols in which the server speaks first wait here. MySQL, PostgreSQL, Redis, SMTP and Memcached ports are opaque by default; NATS is not.

Telemetry

Counting the rings

Shell
linkerd check --pre                        # is the cluster ready?# Gateway API resources must be installed firstlinkerd install --crds | kubectl apply -f -linkerd install --ha | kubectl apply -f -  # three replicas of the control planelinkerd checkkubectl annotate namespace shop linkerd.io/inject=enabledkubectl -n shop rollout restart deploy     # pods get the proxy at creationlinkerd viz install | kubectl apply -f -linkerd viz stat-outbound -n shop deploy/web    # before and after retrieslinkerd viz tap -n shop deploy/web              # live samples of requests
Viz is an extension with a dashboard. Keep long-term metrics in your own monitoring system.

Outbound numbers are shown per route, after retries, and per backend, before them. A route at 100% over a backend at 90% means that retries hide a problem. Linkerd measures what it sees from outside: it cannot look into the service, and application traces need the application to pass on headers.

Clusters

More than one cluster

A mirrored service through a gateway

Cluster east holds web and a mirrored service named orders-west. Calls to it go through a gateway of cluster west to the orders pods there.
With a flat network, pods can be reached directly and the gateway is left out.
ModePathUse it when
HierarchicalThrough a gateway in the target clusterOnly the gateway address is reachable
Flat (since 2.14)Pod to podClusters share a network; keeps the caller's identity
FederatedOne service name over all clusters, pod to podActive-active copies of a service

All clusters must share a trust anchor, so the default install of each, with its own anchor, cannot be joined.

Failure

What breaks how

FailureEffectPreparation
Destination is downProxies use what they know; new targets cannot be foundHigh availability mode, three replicas
Identity is downNothing at first; after up to 24 hours certificates endAlert early
Injector is downHA: pods wait. Otherwise: pods start without a proxyChoose on purpose; exempt kube-system
One proxy failsIts pod is cut offReplicas, resource requests
Anchor endedAll meshed calls failRotate early; practise once

Releases

Which build do you run?

The project publishes edge releases about every week; each 2.x version has a matching edge build (2.20 is edge-26.6.3). They are generally considered production ready, may change, and a few are marked as not recommended. Stable builds are made by vendors. The best known is Buoyant Enterprise for Linkerd: free to try, free in production for companies with fewer than 50 employees, paid above that. Read the terms before you choose.

Decide

When to choose it, and when not

Choose Linkerd when

  • You run Kubernetes and want mTLS and metrics with little to learn
  • gRPC load is uneven
  • A small team will operate it
  • Latency and memory of the proxy matter
  • Sensible defaults are better than many options

Look elsewhere when

  • You want a mesh without sidecars: Istio ambient or Cilium
  • You need Envoy filters, fault injection of many kinds or WebAssembly plugins
  • Most workloads are virtual machines
  • You need free stable builds from the project itself
  • Only traffic from outside matters: use a gateway

Neighbours

ProductAlikeDifferent
IstiomTLS, routes, policyEnvoy, sidecar or ambient, many more features and settings
EnvoyA proxy for servicesGeneral-purpose, in C++, needs a control plane
ConsulDiscovery and meshOwn registry, strong outside Kubernetes
Client librariesRetries and breakersIn every language again, but no extra hop
API gatewayLimits, routesFor callers outside; works well in front of the mesh

Summary

The whole topic in one minute.

Linkerd adds a small proxy to each pod. Encryption, per-request balancing by latency and metrics come at once; retries, timeouts, breakers, rate limits and access rules are annotations or resources that you add.

Know its edges: Kubernetes first, sidecars only, clients must be meshed for client-side features, plain text from outside is accepted until you forbid it, and certificates of the default installation end after a year. Stable builds come from vendors.

  • A Rust micro-proxy per pod; mTLS, balancing and metrics at once.
  • Outbound does balancing, retries and breakers; inbound does policy and limits.
  • Balancing per request by latency; pair it with a breaker.
  • Plain text is accepted until you set a policy; certificates of a default install end after a year.
  • Edge builds from the project, stable builds from vendors.

Sources