How linkerd/linkerd2 works
Project Type and Purpose
• Linkerd is a cloud-native, ultralight service mesh for Kubernetes. It comprises a control plane (set of microservices running in-cluster), a data-plane proxy (injected as sidecars), a CLI, and optional visualization/telemetry integrations (viz, Jaeger, Grafana).
High-Level Architecture
• External Clients / Users: CLI (linkerd), web UI, Helm.
• Kubernetes Control Plane (API server & etcd).
• Linkerd Control Plane: Destination, Identity, Proxy-Injector, Heartbeat, SP-Validator, Policy-Controller (Rust), Multicluster components, Webhook services (tap, jaeger injector).
• Data Plane: per-pod proxies (injected sidecars).
• Observability / Telemetry: Prometheus, Grafana dashboards, Jaeger.
Main Components & Interactions
a. CLI & Installation
• linkerd CLI invokes Kubernetes APIs (CRDs, Helm charts under charts/) to install control-plane services as pods. It uses the pkg/k8s package to talk to the API server.
b. Kubernetes API & CRDs
• Control-plane services watch CRDs (serviceprofiles, destination profiles) via client-go informers under controller/gen/* and pkg/k8s.
c. Control Plane Microservices
• Destination Service (gRPC API): looks up service endpoints & profiles.
• Identity Service: issues TLS identities to proxies.
• Proxy-Injector Webhook: mutates pod specs to inject the sidecar proxy.
• Heartbeat: liveness for multicluster.
• SP-Validator: validates ServiceProfile CRDs.
• Policy-Controller (Rust): admission webhook enforcing policy CRDs.
• Multicluster Link & Service-Mirror: cross-cluster link controller & CRDs.
• Viz components: metrics-api gRPC/HTTP server, tap gRPC server, web server for UI.
d. Data Plane Proxies
• Injected as init containers + sidecars into each application pod.
• Intercept inbound/outbound traffic, perform mTLS to other proxies, consult Identity & Destination services.
e. Telemetry Integrations
• Proxies emit metrics to Prometheus (via HTTP/metrics endpoint).
• Viz metrics-api reads metrics & policy state for the UI.
• Tap service streams live request/response data to CLI / UI.
• Jaeger injector webhook adds tracing headers; Jaeger collector collects spans.
f. Helm & Charts
• Installation artifacts under charts/, jaeger/charts/, viz/charts/, multicluster/charts/.
Architectural Patterns & Principles
• Control-Plane/Data-Plane separation: Control services (state, config) vs sidecar proxies (fast-path traffic).
• Kubernetes-native: CRDs + admission webhooks for injection & policy.
• Microservices: each function (destination, identity, injector) is its own service.
• RPC-driven: gRPC for control-plane APIs.
• Language Diversity: Go for control-plane & CLI; Rust for policy-controller core logic.
• Declarative config via Helm and CRDs.
• Observability: metrics, tracing, dashboards are first-class.
Key Details to Capture
• Injection & admission flow (webhooks → sidecar injection/policy validation).
• Discovery & identity issuance (proxies contacting control-plane).
• Metrics/tracing pipeline (proxy → metrics-api/Prometheus → Grafana/Jaeger).
• Multicluster linking (gateway & mirroring).
• CLI => cluster (charts, CRDs, commands).