Problem
Cross-cutting concerns such as TLS, logging, metrics and retries are reimplemented in every service and language, drifting out of sync and coupling application releases to infrastructure upgrades.
Also known as: sidecar-container, sidecar-proxy
Deploy supporting functionality in a separate process or container that shares the lifecycle and network namespace of the main application.
Cross-cutting concerns such as TLS, logging, metrics and retries are reimplemented in every service and language, drifting out of sync and coupling application releases to infrastructure upgrades.
A sidecar is a companion process attached to a primary application, like a sidecar on a motorcycle. It extends the application without modifying it and lives and dies with it.
In Kubernetes, containers in one pod share a network namespace and can share volumes. A proxy sidecar intercepts or receives traffic on localhost, applies policy and forwards it.
Pod
+------------------------------+
| app <--localhost--> sidecar|--> network
| \--shared volume--/ |
+------------------------------+
Common roles: mesh proxy for mTLS and retries, log forwarder tailing a shared volume, secret refresher writing credentials to a file, config watcher reloading settings.
Medium - resource overhead multiplied by instance count
Medium - fleet-wide sidecar version rollouts
Medium - two processes to reason about
App starts before sidecar is ready and drops early traffic
Sidecar crash or hang takes down all traffic for that instance
Sidecar keeps a job pod alive after the main container exits