Loopback networking
Both containers talk over localhost. The sidecar intercepts traffic
without crossing the network.
The animated 3D scene could not start in this browser. The written explanation below works on its own.
System design, animated
Give every service logging, security, and traffic control without touching a single line of its code.
Follow the packet02 The pattern
A sidecar is a second process that runs next to your application and handles the chores: proxying traffic, terminating TLS, shipping logs, reporting metrics.
It lives in the same pod, shares the same life cycle, and never asks the application to change. Your service keeps serving. The sidecar deals with the rest.
The name comes from motorcycles. The sidecar carries the luggage; the bike stays a bike.
03 Inside the pod
Containers in a pod share a network namespace and can share volumes. That closeness is what makes the pattern cheap.
Both containers talk over localhost. The sidecar intercepts traffic
without crossing the network.
Log files, sockets, and configs pass through a volume that both containers can read and write.
They start, stop, and scale as a single unit. The scheduler treats the pod as the atom.
apiVersion: v1kind: Podspec: containers: - name: app # your service image: acme/api:1.4 - name: sidecar # rides along image: envoyproxy/envoy:v1.31
04 The flow
Watch one request make the trip. The client never talks to the app directly, and the app only ever sees clean local traffic.
The request arrives at the pod, not at the application.
TLS terminated, identity verified, policy checked, retries armed.
The request hops to the app inside the pod network namespace.
The sidecar observes, meters, and encrypts the trip back.
05 Offloaded work
If every service needs it, and it is not the service's job, it belongs in a sidecar.
Logs, metrics, and traces leave through one door, in one format.
mTLS, token exchange, and certificate rotation, away from app code.
Retries, timeouts, circuit breaking, and rate limits per route.
Service lookup and health checks, so callers find healthy pods only.
Feature flags and secrets refreshed without restarting the app.
gRPC to HTTP, JSON to protobuf, old protocol to new.
The app rests while the sidecar works. That division of labor is the whole idea.
06 Trade-offs
A sidecar costs resources and adds a hop to every call. It pays for itself when a concern is universal and untouchable.
Seen in the wild
Use a sidecar when a concern applies to every service and belongs to none of them.