Asterrr's Handbook

Service mesh

What a service mesh adds to Kubernetes networking, data plane vs control plane, sidecar vs Istio ambient mode, mTLS and workload identity, traffic management, Istio and Linkerd, and the Gateway API GAMMA initiative.

Exam tasks: 2.1 (networking: service mesh)

The decision: does this requirement (encrypt all service-to-service traffic, retry failed calls, shift 5% of traffic to a new version, see per-call latency) need a service mesh, and if so, which data plane model?

What a mesh adds

Kubernetes Services give you discovery and simple load balancing. A service mesh moves the rest of service-to-service concerns out of application code and into infrastructure:

AreaWhat the mesh doesWithout a mesh
SecurityMutual TLS between workloads, identity-based authorization policiesEach app implements TLS and auth itself
Traffic managementRetries, timeouts, circuit breaking, weighted routing, mirroring, fault injectionClient libraries in every language
ObservabilityGolden metrics (requests, errors, latency) per call, distributed tracing headers, access logsInstrument each service by hand
  • The mesh handles east-west traffic (service to service inside the cluster). North-south traffic still enters through a Gateway or Ingress, which the mesh can also secure.
  • Apps don't change. The mesh intercepts traffic transparently.

Data plane and control plane

  • The data plane is the set of proxies that actually carry traffic.
  • The control plane programs those proxies, issues workload certificates and watches the Kubernetes API for Services and endpoints. It is not in the request path.

Sidecar vs ambient

SidecarIstio ambient
Where the proxy runsOne proxy container in every Podztunnel per node (DaemonSet) for L4, optional waypoint proxies for L7
Joining the meshInject the sidecar, then restart PodsLabel the namespace; no Pod restart
Resource costProxy CPU and memory per PodShared per node; L7 cost only where waypoints are deployed
L7 featuresAlways availableOnly for workloads behind a waypoint
StatusThe classic model for Istio and LinkerdGA since Istio 1.24
  • ztunnel handles mTLS, L4 authorization and TCP telemetry. A waypoint (an Envoy proxy, usually per namespace) adds HTTP routing, retries and L7 policy.
  • Kubernetes also has native sidecar containers (init containers with restartPolicy: Always), which start before and stop after the app container. Meshes use them to fix startup and Job-completion ordering problems.

Exam signal

"Add a mesh without injecting a proxy into every Pod" or "reduce per-Pod proxy overhead" points to ambient mode (ztunnel plus waypoints). "Each Pod has an extra container that intercepts its traffic" describes the sidecar model.

mTLS and workload identity

  • In plain TLS only the server proves who it is. In mutual TLS, both sides present certificates, so the server also knows which workload is calling.
  • The mesh control plane acts as a certificate authority. It issues short-lived certificates to each workload, usually tied to the Pod's ServiceAccount, and rotates them automatically.
  • Istio identities follow SPIFFE (spiffe://<trust-domain>/ns/<namespace>/sa/<serviceaccount>). SPIFFE and its reference implementation SPIRE are CNCF graduated.
  • Authorization policies can then say "only the checkout ServiceAccount may call billing", which is stronger than IP-based rules because Pod IPs change.
  • Linkerd turns on mTLS automatically for all meshed TCP traffic. Istio supports permissive mode (accept plain text and mTLS during migration) and strict mode (mTLS only).

NetworkPolicy as encryption

A NetworkPolicy decides whether two Pods may connect. It doesn't encrypt anything and doesn't know workload identity. "Encrypt all Pod-to-Pod traffic and verify both sides" needs mTLS from a service mesh (or a CNI with transparent encryption), not a NetworkPolicy.

Traffic management

  • Retries and timeouts: the proxy retries failed calls and gives up after a deadline, so apps don't need their own retry logic.
  • Circuit breaking: stop sending traffic to an instance that keeps failing (outlier detection), so one bad replica doesn't drag down callers.
  • Weighted routing: send 90% to v1 and 10% to v2 for a canary, independent of replica counts.
  • Traffic mirroring: copy live requests to a new version and discard its responses.
  • Fault injection: add delays or errors on purpose to test resilience.

The projects

IstioLinkerd
CNCF statusGraduated (2023)Graduated (2021), the first service mesh to graduate
Data planeEnvoy (sidecar), or ztunnel plus Envoy waypoints (ambient)linkerd2-proxy, a small purpose-built Rust proxy (sidecar)
StrengthsVery broad feature set, ambient mode, multi-clusterSimplicity, low overhead, mTLS on by default
  • Envoy (CNCF graduated) is a general-purpose L7 proxy. It's the data plane of Istio and of many Gateway API controllers. It's a proxy, not a mesh by itself.
  • Cilium offers mesh features (mTLS, L7 policy) using eBPF and per-node Envoy, without sidecars.

Standards: from SMI to GAMMA

Legacy: use Gateway API (GAMMA) instead

The Service Mesh Interface (SMI) was a CNCF sandbox spec for a common mesh API (traffic split, access control, metrics). It was archived in 2023. Its role passed to the Gateway API GAMMA initiative.

  • GAMMA (Gateway API for Mesh Management and Administration) uses the same HTTPRoute you use for ingress, but attaches it to a Service instead of a Gateway. The route then applies to traffic going to that Service inside the mesh.
  • Mesh support is part of the Gateway API standard channel since v1.1. Istio, Linkerd and Cilium implement it.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: recommender-canary
  namespace: shop
spec:
  parentRefs:
    - group: ""
      kind: Service
      name: recommender
      port: 8080
  rules:
    - backendRefs:
        - name: recommender-v1
          port: 8080
          weight: 90
        - name: recommender-v2
          port: 8080
          weight: 10
mTLS
Both sides authenticate with certificates; the mesh issues and rotates them.
Istio 1.24
Release where ambient mode became GA.
Graduated
CNCF status of both Istio and Linkerd.
Archived
Status of SMI; use Gateway API GAMMA instead.

Scenarios

Scenario
A company runs 40 microservices written in four languages. Security requires that all service-to-service traffic is encrypted and that each service can verify the identity of its caller, without changing application code. What should they adopt?
Scenario
A team using Istio wants mesh mTLS for a large namespace but cannot afford an extra proxy container in each of its hundreds of Pods, and does not want to restart the Pods. Which approach fits BEST?
Scenario
An architect wants a vendor-neutral Kubernetes API for configuring traffic splitting between services inside a mesh, so the configuration works across mesh implementations. What should they use?

Further reading

On this page