What is a Sidecar Pattern

The sidecar pattern deploys a secondary process (the sidecar) alongside the main application process. The sidecar handles cross-cutting concerns — logging, monitoring, networking, TLS, configuration — so the application does not have to.

How it works

In a containerized environment like Kubernetes, the sidecar runs as a separate container in the same pod as the application container. They share the same network namespace (localhost), filesystem mounts, and lifecycle. The sidecar intercepts or augments the application's traffic without the application needing any code changes.

Common sidecar responsibilities:

  • Proxy — Envoy intercepts all network traffic for mutual TLS, retries, and observability. This is the foundation of a service mesh.
  • Log collection — a sidecar ships logs from the application container to a centralized logging system.
  • Configuration — a sidecar watches a configuration store and updates local files when values change.

Why it matters

The sidecar pattern separates infrastructure concerns from business logic. The application code stays focused on its domain. The sidecar can be written in a different language, maintained by a different team, and upgraded independently.

The tradeoff is resource consumption (every pod gets an extra container) and operational complexity (more containers to monitor, debug, and configure). In service meshes with thousands of services, sidecars add significant memory and CPU overhead, which is why some systems are moving to sidecar-less architectures (Cilium, ambient mesh).