Sidecar pattern — containers running alongside the main application container in a single Kubernetes pod. They share network + volumes but are separate processes. Used for: log shipping (Fluent Bit sidecar), service mesh (Envoy proxy), config reload (watch ConfigMap), secrets sync (Vault agent), data synchronization. Main plus: separation of concerns without application code changes.
Below: details, example, related terms, FAQ.
# Pod with sidecar
spec:
containers:
- name: app
image: my-app:v1
- name: log-shipper # sidecar
image: fluent/fluent-bit
volumeMounts:
- { name: logs, mountPath: /var/log }
volumes:
- name: logs
emptyDir: {}Sidecar — separate container (different image + update cycle). Multi-process — all in one image (anti-pattern in K8s, needs supervisord). Sidecar cleaner.
Each sidecar adds: ~30-100 MB memory, CPU slice. In 100-pod cluster — significant. Use only when needed.
Sidecar crash → pod kill if restartPolicy: Always. Use lifecycle hooks + proper readiness probe.