A sidecar is a helper container that runs alongside the main application container in the same Kubernetes pod and shares its lifecycle, network namespace and optionally volumes. Sidecars add cross-cutting functions such as service mesh proxying, log forwarding, certificate rotation or telemetry collection without changing the application code.
What is a sidecar?
A sidecar is a secondary container that is deployed together with an application container, like a sidecar attached to a motorcycle. In Kubernetes both live in the same pod: they are scheduled onto the same node, share the network namespace (so they talk via localhost) and can share volumes. The application stays focused on business logic, while the sidecar takes care of a cross-cutting concern.
The sidecar pattern became popular with microservices and container platforms because it lets platform teams roll out the same functionality to many services, regardless of the programming language those services are written in.
Typical use cases
- Service mesh proxies: in a classic service mesh such as Istio or Linkerd, a proxy sidecar intercepts all inbound and outbound traffic and handles mTLS, retries, routing and metrics.
- Log shipping: an agent reads log files from a shared volume and forwards them, useful for legacy applications that cannot log to stdout.
- Telemetry collection: an OpenTelemetry Collector runs per pod, receives OTLP from the application on
localhost, enriches the data and forwards it. - Security and configuration: sidecars that fetch secrets, rotate certificates or reload configuration.
- Adapters: translating an application's proprietary metrics format into one a monitoring system understands.
Native sidecar containers in Kubernetes
For a long time Kubernetes had no concept of a sidecar. Sidecars were ordinary containers, which caused well-known problems: a log shipper could start after the application and miss its first lines, and Jobs never finished because the sidecar kept running after the main container exited.
Kubernetes therefore introduced native sidecar containers: an init container with restartPolicy: Always. It starts before the regular containers, keeps running for the whole pod lifetime, is shut down after the main containers and does not block Job completion. The feature arrived as alpha in Kubernetes 1.28, was enabled by default from 1.29 and is stable in 1.33.
spec:
initContainers:
- name: otel-collector
image: otel/opentelemetry-collector-contrib
restartPolicy: Always
containers:
- name: app
image: shop/checkout:1.4.2
Native sidecars can also have their own probes, and their readiness counts toward the readiness of the pod.
Trade-offs and alternatives
Sidecars are flexible but not free. Every sidecar consumes CPU and memory in every pod, so a cluster with hundreds of pods also runs hundreds of proxies or collectors. Each sidecar adds start-up time, an upgrade path and potential failure modes. Common alternatives are:
| Approach | Scope | Typical use |
|---|---|---|
| Sidecar | One per pod | Per-application config, isolation, legacy log files |
| DaemonSet agent | One per node | Node metrics, container logs, cost-efficient collection |
| Gateway / central collector | One per cluster or region | Tail sampling, routing, central processing |
| eBPF-based agent | Kernel level per node | Network and process telemetry without code or pod changes |
Service meshes have followed the same path: Istio's ambient mode replaces per-pod proxies with per-node and optional per-namespace components, and other projects rely on eBPF.
A practical rule of thumb: start with a node-level agent and a central gateway, and add sidecars only where a workload has a concrete reason, such as strict tenant isolation, a special processing pipeline or log files that cannot be read otherwise. Keep sidecar images and versions managed centrally, for example through admission webhooks or an operator that injects them, so that hundreds of pods do not drift to different versions. Set explicit CPU and memory requests for each sidecar, because they count toward the pod's resources and its scheduling.
Sidecars and observability
For telemetry, a sidecar collector makes sense when each application needs its own processing rules, when you want to isolate tenants, or when the application should export to localhost without knowing the network topology. In most clusters a node-level agent plus a central gateway is more resource-efficient. The OpenTelemetry Operator supports both models and can inject a collector sidecar via the annotation sidecar.opentelemetry.io/inject. Remember to monitor the sidecars themselves: a saturated proxy or a crashing collector shows up as latency or missing data in the application.
How Obseria helps
Obseria accepts OTLP from sidecar, node-level and gateway collectors alike, so you can choose the deployment model per workload. Kubernetes monitoring shows resource usage and restarts of sidecars separately from the main container, and the Obseria Pipeline can take over filtering and masking centrally instead of in every pod.