Lesson 2 · Service-mesh fundamentals
The sidecar & injection
How an Envoy proxy appears in your Pod and quietly takes over its network.
Your win: explain how the Envoy sidecar is added (automatic, namespace-based injection), how it transparently intercepts traffic, and this repo's revision-based setup and opt-outs.
The sidecar pattern
Recall Course 1: a Pod can hold more than one container, sharing a network namespace (one
IP). Istio uses that. Alongside your build/server container, it adds an
Envoy container — the sidecar. Because they share the Pod's
network, Istio can reroute the Pod's traffic through Envoy: your app still connects to
localhost, but Envoy intercepts inbound and outbound connections and applies the
mesh's rules.1 Your code doesn't know it's there.
Injection — how the sidecar gets in
You don't add Envoy by hand. Automatic sidecar injection: a mutating
admission webhook rewrites new Pods to include the Envoy container — but only in namespaces
that have opted in via a label.2 The classic label is
istio-injection=enabled; the newer, revision-aware form is
istio.io/rev=<revision-tag> (so you can run multiple istiod versions and
migrate namespaces one at a time).
revision: 1-18-5 and a revisionTag of stable
(prod) / local, with defaultRevision: 1-18-5 on istio-base
(deployments/helm/platforms/istio/skaffold.yaml:16). A backend
namespace opts in with istio.io/rev=stable, and every Pod there is auto-injected.
The repo also tunes the sidecar's resources via pod annotations —
sidecar.istio.io/proxyCPU: 10m, proxyMemory: 50Mi
(libs/util/templates/_workload_metadata.tpl:16-17).
sidecar.istio.io/inject: "false" are kept out: the gandalf
test/BDD pods (backend/gandalf/templates/deployment.yaml:20,77),
and one-shot Jobs / CronJobs / migration hooks (Course 3 L7) — because a
Job that runs to completion would otherwise hang forever waiting on a sidecar that never
exits. Recognising when not to inject is a real operational skill.
holdApplicationUntilProxyStarts: true
(platforms/istio/istiod-values.yaml) — the app container waits
for Envoy to be ready before starting, so early requests aren't sent before the sidecar can
route them. A small but important ordering guarantee.
Istio docs — Installing the sidecar (injection)
Automatic vs manual injection, the namespace label / revision tag, and how the webhook rewrites the Pod.
→ istio.io — Installing the Sidecar
→ istio.io — Data plane modes (sidecar vs ambient)
Check yourself (from memory)
Q1. The Envoy sidecar can intercept a Pod's traffic because…
Q2. Automatic injection is triggered by…
istio.io/rev=stable here).
Q3. Why do this repo's Jobs and gandalf pods set inject: "false"?
istio-injection=enabled or revision-aware istio.io/rev=<tag>.
REPO: revision-based (revision: 1-18-5, tag stable/local,
defaultRevision on base); sidecar resources tuned via
sidecar.istio.io/proxyCPU/Memory annotations. OPT-OUT with
sidecar.istio.io/inject: "false" — gandalf test pods + Jobs/CronJobs/migration
hooks (a Job would hang on a non-exiting sidecar). holdApplicationUntilProxyStarts
makes the app wait for Envoy.