A Sidecar container is a helper container that runs alongside your main application container in the same Pod and helps it do its job.
Think of your application as a car, and the sidecar is like a co-driver or a support vehicle — it’s not the driver, but helps with navigation, music, tools, or repairs.
Why Use a Sidecar?
A Sidecar container is used to:
- Monitor your app (e.g., log collection)
- Update configs or certificates dynamically
- Proxy traffic (e.g., Envoy or Istio sidecar)
- Backup data to a remote server
- Synchronize files or cache
Real-Life Examples:
- Logging Agent
App writes logs → Sidecar reads logs and sends to ELK or Grafana. - Envoy Proxy
App sends requests → Sidecar Envoy container handles encryption or routing. - Database Backup
Main app stores files → Sidecar regularly backs up data to S3.
Real-Life Analogy:
- Init Container = setting up a restaurant before opening (cleaning, placing tables, checking kitchen)
- Sidecar Container = staff working during service (waiter, music system, cashier)
Sidecar container always available and check all things like logs and all.
If we enable restart policy in init container then it can work like sidecar container.