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:
- 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. - Load balancing: Fine-grained strategies including round-robin, least-request, and random across upstream replicas.
- 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.
- Circuit breakers: Trips automatically when an upstream service becomes unresponsive, stopping requests to that failing service while letting healthy services run normally.
- %-based traffic splitting: Splits traffic across service versions by percentage (e.g., 10% to
v2and 90% tov1for canary deployments or A/B testing, then gradually rampingv2to 100%). - 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)
- Load balancing for HTTP, WebSocket, and TCP traffic.
- Fine-grained traffic control (rich routing rules, retries, failovers, fault injection).
- A policy layer and configuration API for access controls and rate limits.
- Automatic metrics, logs, and traces for all cluster traffic, including ingress and egress.
- 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)
| Plane | What it is in Istio | Role | In the path of user requests? |
|---|---|---|---|
| Data Plane | The set of proxies (e.g., Envoy / ztunnel) | Mediates and controls all network traffic between microservices; collects and reports telemetry | Yes — handles every packet/request |
| Control Plane | Istio control plane | Translates operator YAML into proxy rules and configures/manages the data plane proxies | No — 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- Inbound capture: Traffic arrives at the Pod’s virtual Ethernet interface (
veth) destined for portX1.iptablesintercepts traffic targetingX1and redirects it to Envoy’s inbound portX2. - Localhand-off: Envoy inspects/applies mesh policies and sends the request to
localhoston portX1via theloopbackinterface. - App delivery: Application 1 receives the request on its normal socket (
X1), unaware of the proxy. - Outbound reply: Application 1 generates its reply toward the remote client.
- Outbound capture:
iptablesintercepts the outgoing reply and redirects it into userspace to Envoy on portX3. - External forwarding: Envoy forwards the reply out through
vethto the remote requester over another TCP connection.
Common confusion: Why does Envoy deliver to App 1 via
loopback(localhost) instead ofveth?Two reasons: (1) both containers live inside the same Pod network namespace, so
loopbackis the internal wire directly to App 1’s listening socket; and (2) sending traffic back throughvethto portX1would hit theiptablesinbound 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:
- Invasiveness: Injecting sidecars modifies Kubernetes Pod specs and traffic redirection inside the Pod. Installing or upgrading Envoy requires restarting every application Pod.
- 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.
- 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:
| Layer | Capabilities | Needed by |
|---|---|---|
| Secure Overlay Layer (L4) | Streamlined, low-resource zero trust: TCP routing, mTLS tunneling, simple authorization policies, TCP metrics & logging | Typically always needed |
| L7 Processing Layer | All Secure Overlay features plus HTTP routing & LB, circuit breaking, rate limiting, fault injection, retries, timeouts, rich authorization, HTTP metrics, access logging, distributed tracing | Opt-in only (not always needed) |
Ambient Mode components (PDF p. 32 / printed slide 34)
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).Waypoint proxies: Optional Envoy-based Layer 7 proxies deployed at the namespace level (e.g., forS 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:
istio-cnienters the workload Pod’s Linux network namespace and writesiptablesredirection rules pointing to the node-localztunnel.istio-cninotifies theztunnelPod on that node that a new workload needs proxying.ztunnelinternally spins up a dedicated logical proxy instance and creates listening sockets directly inside the workload Pod’s network namespace.- 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
| Dimension | Sidecar Mode | Ambient Mode |
|---|---|---|
| Proxy placement | 1 Envoy container injected inside every Pod | Shared ztunnel per Node + opt-in waypoint per Namespace |
| Layer model | All-or-nothing (L4 + L7 together) | Layered: L4 always on (ztunnel); L7 opt-in (waypoint) |
| Upgrading the data plane | Invasive: requires restarting application Pods | Non-invasive: decoupled from Pod specs (no Pod restarts) |
| Resource efficiency | Lower (worst-case reservations per Pod) | Higher (shared node proxy; L7 Envoy only where requested) |
| Traffic capture mechanism | MutatingWebhook injects container + in-Pod iptables | istio-cni writes iptables + ztunnel opens sockets in Pod netns |
Retrieval
- 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. - Trace the 6-step
iptablessidecar interception path for an incoming request to Application 1 on portX1, and explain why Envoy forwards the request to App 1 overloopbackinstead ofveth.
(1) Inbound packet onvethtargetingX1is redirected byiptablesto Envoy onX2; (2) Envoy checks policies and sends tolocalhost:X1vialoopback; (3) App 1 receives it onX1; (4) App 1 replies; (5)iptablesredirects the reply to Envoy onX3; (6) Envoy sends the reply out viavethover another TCP connection. Usingloopbackworks because App 1 and Envoy share the Pod’snetnamespace, and avoids re-triggering thevethiptablesrule in an infinite loop. - 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-nodeztunnel, while only the 40 services needing HTTP canary routing and circuit breaking opt in to Envoy-basedwaypointproxies.
Source: Lecture 13 - Service Mesh and Istio, PDF pages 17–33 (printed slides 19–35).