Envoy Proxy and Istio Sidecar vs. Ambient Mode

Envoy: the data plane proxy

Envoy is a high-performance proxy written in C++ that mediates all inbound and outbound traffic for services in a service mesh (PDF pp. 17–22 / printed slides 19–24). Out of the box, Envoy provides six core capabilities:

  1. Dynamic service discovery: When Kubernetes adds a new Pod to a service (e.g., backend-service), Envoy dynamically updates its routing tables with the new Pod’s IP so it starts receiving traffic immediately.
  2. Load balancing: Fine-grained strategies including round-robin, least-request, and random across upstream replicas.
  3. HTTP/2 and gRPC proxies: Full support for HTTP/2 and gRPC, multiplexing multiple streams over a single TCP connection to lower latency and raise throughput.
  4. Circuit breakers: Trips automatically when an upstream service becomes unresponsive, stopping requests to that failing service while letting healthy services run normally.
  5. %-based traffic splitting: Splits traffic across service versions by percentage (e.g., 10% to v2 and 90% to v1 for canary deployments or A/B testing, then gradually ramping v2 to 100%).
  6. Rich metrics: Exposes detailed traffic, latency, error-rate, and resource metrics integrable with Prometheus or Datadog (see Observability Metrics and Prometheus).

Istio architecture: Control Plane vs. Data Plane

Manually configuring a fleet of hundreds of Envoy proxies is verbose and error-prone (PDF p. 24 / printed slide 26). Istio acts as the control plane that abstracts Envoy concepts into familiar Kubernetes-style YAML files managed with kubectl or istioctl.

Istio’s five main pillars (PDF p. 26 / printed slide 28)

  1. Load balancing for HTTP, WebSocket, and TCP traffic.
  2. Fine-grained traffic control (rich routing rules, retries, failovers, fault injection).
  3. A policy layer and configuration API for access controls and rate limits.
  4. Automatic metrics, logs, and traces for all cluster traffic, including ingress and egress.
  5. Secure service-to-service communication with strong identity-based authentication and authorization (mTLS).

Separating Data Plane and Control Plane (PDF p. 27 / printed slide 29)

PlaneWhat it is in IstioRoleIn the path of user requests?
Data PlaneThe set of proxies (e.g., Envoy / ztunnel)Mediates and controls all network traffic between microservices; collects and reports telemetryYes — handles every packet/request
Control PlaneIstio control planeTranslates operator YAML into proxy rules and configures/manages the data plane proxiesNo — configuration & identity only

Key operational consequence: Control Plane outage

If Istio’s Control Plane crashes temporarily while Pods and proxies stay running, Service A and Service B continue communicating normally, because the Data Plane proxies already hold their routing and mTLS rules. You only lose the ability to push new configuration changes until the Control Plane recovers.

Istio Sidecar Mode (2017)

In Sidecar Mode, every application Pod gets its own dedicated Envoy proxy container injected alongside the application container. Both proxies process both Layer 4 and Layer 7 traffic.

Automatic injection (MutatingWebhooks, PDF p. 28 / printed slide 30)

Operators do not rewrite application code or manually paste Envoy containers into every YAML. Kubernetes MutatingWebhooks (see Kubernetes Extensibility CRDs Operators Webhooks and Drivers) watch Pod creation in mesh-enabled namespaces and transparently modify the Pod specification to inject the Envoy sidecar container before scheduling.

Under the hood: how a sidecar “steals” traffic via iptables (PDF p. 25 / printed slide 27)

Inside a Kubernetes Pod, container1 (Application 1, listening on TCP port X1) and container2 (User-level TCP proxy / Envoy, listening on ports X2 and X3) share the same Linux network namespace (net namespace, see Kubernetes Pods Sidecars and Workload Controllers). Because they share one network stack, Pod-level iptables rules transparently intercept all traffic without the application knowing Envoy exists:

Inbound:  veth ("public" Pod IP) ─(1) iptables redirects dst :X1 to :X2─► Proxy (:X2)
                                                                            │
                                                      (2) sends to localhost:X1 via loopback
                                                                            ▼
                                                                   App 1 (listens :X1)
                                                                            │
Outbound: App 1 sends reply ─(5) iptables redirects outbound to :X3─► Proxy (:X3)
                                                                            │
                                            (6) forwards reply over new TCP conn via veth
  1. Inbound capture: Traffic arrives at the Pod’s virtual Ethernet interface (veth) destined for port X1. iptables intercepts traffic targeting X1 and redirects it to Envoy’s inbound port X2.
  2. Localhand-off: Envoy inspects/applies mesh policies and sends the request to localhost on port X1 via the loopback interface.
  3. App delivery: Application 1 receives the request on its normal socket (X1), unaware of the proxy.
  4. Outbound reply: Application 1 generates its reply toward the remote client.
  5. Outbound capture: iptables intercepts the outgoing reply and redirects it into userspace to Envoy on port X3.
  6. External forwarding: Envoy forwards the reply out through veth to the remote requester over another TCP connection.

Common confusion: Why does Envoy deliver to App 1 via loopback (localhost) instead of veth?

Two reasons: (1) both containers live inside the same Pod network namespace, so loopback is the internal wire directly to App 1’s listening socket; and (2) sending traffic back through veth to port X1 would hit the iptables inbound rule again, creating an infinite redirection loop.

Limitations of Sidecar Mode (PDF p. 29 / printed slide 31)

Although thoroughly battle-tested, Sidecar Mode couples the proxy lifecycle to every application Pod:

  1. Invasiveness: Injecting sidecars modifies Kubernetes Pod specs and traffic redirection inside the Pod. Installing or upgrading Envoy requires restarting every application Pod.
  2. Underutilization of resources: Because each sidecar is dedicated to one Pod, CPU and memory must be provisioned for that individual Pod’s worst-case traffic—adding up to large wasted reservations across the cluster.
  3. Traffic breaking: Capturing and parsing every HTTP stream in Envoy is computationally expensive and can break applications with non-conformant HTTP implementations.

Istio Ambient Mode (2022 / Istio 1.22+)

Launched in 2022 and production-ready for single-cluster use cases as of Istio 1.22, Ambient Mode solves Sidecar Mode’s limitations by eliminating per-Pod sidecars and slicing the data plane into two layers (PDF pp. 30–33 / printed slides 32–35).

Slicing the layers (PDF p. 31 / printed slide 33)

Traditional sidecars are all-or-nothing: a service that only needs encrypted mTLS connections still pays the CPU, memory, and HTTP-parsing cost of full Layer 7 processing. Ambient Mode splits these responsibilities:

LayerCapabilitiesNeeded by
Secure Overlay Layer (L4)Streamlined, low-resource zero trust: TCP routing, mTLS tunneling, simple authorization policies, TCP metrics & loggingTypically always needed
L7 Processing LayerAll Secure Overlay features plus HTTP routing & LB, circuit breaking, rate limiting, fault injection, retries, timeouts, rich authorization, HTTP metrics, access logging, distributed tracingOpt-in only (not always needed)

Ambient Mode components (PDF p. 32 / printed slide 34)

  1. ztunnel (Zero-Trust Tunnel): A shared, Layer 4-only proxy running on every Kubernetes node (one per node, not one per Pod). Its job is to securely connect and authenticate workloads using HTTPS CONNECT tunnels (mTLS).
  2. Waypoint proxies: Optional Envoy-based Layer 7 proxies deployed at the namespace level (e.g., for S Namespace). Only namespaces/workloads that opt in to L7 features route through a waypoint proxy.

How Ambient Mode captures traffic without a sidecar container (PDF p. 33 / printed slide 35)

Instead of injecting an Envoy container into the Pod spec, Ambient Mode uses istio-cni and ztunnel together:

  1. istio-cni enters the workload Pod’s Linux network namespace and writes iptables redirection rules pointing to the node-local ztunnel.
  2. istio-cni notifies the ztunnel Pod on that node that a new workload needs proxying.
  3. ztunnel internally spins up a dedicated logical proxy instance and creates listening sockets directly inside the workload Pod’s network namespace.
  4. Traffic now flows transparently through ztunnel (and detours through a waypoint proxy only if L7 features are enabled for that namespace).

Sidecar Mode vs. Ambient Mode compared

DimensionSidecar ModeAmbient Mode
Proxy placement1 Envoy container injected inside every PodShared ztunnel per Node + opt-in waypoint per Namespace
Layer modelAll-or-nothing (L4 + L7 together)Layered: L4 always on (ztunnel); L7 opt-in (waypoint)
Upgrading the data planeInvasive: requires restarting application PodsNon-invasive: decoupled from Pod specs (no Pod restarts)
Resource efficiencyLower (worst-case reservations per Pod)Higher (shared node proxy; L7 Envoy only where requested)
Traffic capture mechanismMutatingWebhook injects container + in-Pod iptablesistio-cni writes iptables + ztunnel opens sockets in Pod netns

Retrieval

  1. In an Istio Sidecar mesh of 200 microservices, the Istio Control Plane crashes for 3 minutes while all workload Pods remain healthy. Does service-to-service traffic stop? Explain why.
    No. Traffic continues flowing because the Data Plane (Envoy sidecars) handles all live requests directly and already holds its cached routing tables and mTLS configuration. Only new configuration updates or newly pushed routing/policy changes are paused until the Control Plane recovers.
  2. Trace the 6-step iptables sidecar interception path for an incoming request to Application 1 on port X1, and explain why Envoy forwards the request to App 1 over loopback instead of veth.
    (1) Inbound packet on veth targeting X1 is redirected by iptables to Envoy on X2; (2) Envoy checks policies and sends to localhost:X1 via loopback; (3) App 1 receives it on X1; (4) App 1 replies; (5) iptables redirects the reply to Envoy on X3; (6) Envoy sends the reply out via veth over another TCP connection. Using loopback works because App 1 and Envoy share the Pod’s net namespace, and avoids re-triggering the veth iptables rule in an infinite loop.
  3. A cluster has 500 microservices: all 500 require zero-trust mTLS encryption, but only 40 require HTTP canary splitting and circuit breaking. Which Istio mode fits better, and which components serve the 500 vs. the 40 services?
    Ambient Mode fits much better because it slices L4 and L7 rather than forcing heavy L7 Envoy sidecars onto all 500 Pods. All 500 services get lightweight L4 mTLS tunneling from the shared per-node ztunnel, while only the 40 services needing HTTP canary routing and circuit breaking opt in to Envoy-based waypoint proxies.

Source: Lecture 13 - Service Mesh and Istio, PDF pages 17–33 (printed slides 19–35).