> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sidecar

> Explains the sidecar pattern in service meshes, focusing on Envoy proxies, sidecar injection, traffic management, security, observability, and control planes like Istio.

Before we learn what [Istio](https://learn.kodekloud.com/user/courses/istio-service-mesh) is, it helps to understand the sidecar pattern.

Think back to learning how to ride a bicycle: you struggle to keep balance and might fall. A motorcycle sidecar—popular in the mid-20th century—attaches to the vehicle to provide stability and carry an extra passenger who can help with navigation or watch for traffic. In software, a sidecar runs alongside your application and offloads supporting responsibilities so the primary application can focus on its core functionality.

A sidecar typically handles tasks like monitoring traffic, managing communications on behalf of the application, and providing auxiliary features (security, routing, observability). In short: it absorbs cross-cutting concerns, organizes and navigates network traffic, and communicates with other services so the application itself doesn’t need to.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zDpSzOByf0QVxNkX/images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/sidecar-role-numbered-boxes-slide.jpg?fit=max&auto=format&n=zDpSzOByf0QVxNkX&q=85&s=179191b0a2a3d52d3a70fa49885808ae" alt="A presentation slide titled &#x22;Role of a Sidecar&#x22; showing four numbered, colored boxes with brief descriptions: it handles extra tasks, organizes insurance and license info, enhances safety with collision alerts and navigation, and communicates with others. The layout uses gradient number icons on the left and rounded text boxes on the right." width="1920" height="1080" data-path="images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/sidecar-role-numbered-boxes-slide.jpg" />
</Frame>

Service meshes rely on sidecar proxies to manage traffic between services. Popular proxy implementations include:

| Proxy / Mesh   | Typical Use                                   | Notes / Example                                                                                    |
| -------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| Envoy Proxy    | Default sidecar proxy for many service meshes | Used (in an extended form) by [Istio](https://learn.kodekloud.com/user/courses/istio-service-mesh) |
| Linkerd2 proxy | Lightweight proxy used by Linkerd             | Focuses on simplicity and low overhead                                                             |
| Traefik Proxy  | Used by Traefik Mesh and ingress scenarios    | Good for HTTP routing and modern edge scenarios                                                    |
| HAProxy        | General-purpose proxy/load balancer           | Can be used in custom setups (e.g., with `HashiCorp Consul`)                                       |

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zDpSzOByf0QVxNkX/images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/options-envoy-traefik-linkerd-haproxy.jpg?fit=max&auto=format&n=zDpSzOByf0QVxNkX&q=85&s=1acc8d8e4452303b7cb7214123ca520d" alt="A slide titled &#x22;Options&#x22; showing four service/proxy logos: Envoy, Traefik, Linkerd, and HAProxy." width="1920" height="1080" data-path="images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/options-envoy-traefik-linkerd-haproxy.jpg" />
</Frame>

Envoy is an open-source, high-performance proxy originally developed at Lyft and later adopted by the Cloud Native Computing Foundation (CNCF). It behaves like a modern, dynamic load balancer with rich observability features, making it ideal for cloud-native microservices architectures. Note that the terms "proxy" and "sidecar" are often used interchangeably — both refer to the component that runs alongside your application to manage network traffic.

<Callout icon="lightbulb" color="#1CB2FE">
  "Sidecar injection" is the process of automatically adding a proxy (for example, an Envoy sidecar) to a workload so it runs alongside the application container.
</Callout>

How does a sidecar proxy operate in practice? Think of Envoy as a traffic controller for your services. In a distributed system with many services, Envoy intercepts inbound and outbound traffic for each workload (typically as a separate container in the same Kubernetes Pod), ensuring requests are routed securely and efficiently to their destinations.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zDpSzOByf0QVxNkX/images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/kubernetes-middleman-service-mesh-schematic.jpg?fit=max&auto=format&n=zDpSzOByf0QVxNkX&q=85&s=4c3b1327e5b2835567f870e922f1da35" alt="A schematic diagram of a Kubernetes &#x22;Service Mesh&#x22; titled &#x22;Middleman.&#x22; It shows three nodes, each running an app and its service with Envoy sidecar proxies interconnected to form the mesh." width="1920" height="1080" data-path="images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/kubernetes-middleman-service-mesh-schematic.jpg" />
</Frame>

As the middleman, Envoy provides many important features:

* Traffic routing and intelligent load balancing across service instances.
* TLS / mTLS termination and encryption when configured (typically via a control plane such as [Istio](https://learn.kodekloud.com/user/courses/istio-service-mesh)).
* Observability: metrics, logs, and distributed tracing hooks to monitor request rates, latencies, and errors.
* Reliability features: retries, circuit breaking, rate limiting, and traffic mirroring.
* Advanced traffic control: header-based routing, fault injection, and traffic shifting.

Why include Envoy (or another sidecar proxy) in your service mesh?

* Simplified communication: a consistent network layer so application code doesn’t implement complex networking logic.
* Security: service-to-service encryption and identity (for example, mTLS).
* Performance and observability: centralized metrics and tracing points for all service-to-service traffic.
* Reliability and control: circuit breakers, rate limits, and retries improve resilience and operational control.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zDpSzOByf0QVxNkX/images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/envoy-proxy-benefits-communication-security-performance.jpg?fit=max&auto=format&n=zDpSzOByf0QVxNkX&q=85&s=8379fa5a5c1479766859f3a8bc8eb6ae" alt="A presentation slide titled &#x22;Why Use Envoy Proxy?&#x22; showing three benefits—Simplified Communication, Security, and Performance—each with an icon and a brief explanation of how Envoy improves app communication, secures data, and tracks application health." width="1920" height="1080" data-path="images/Prep-Course-Istio-Certified-Associate-ICA-Certification/Introduction/Sidecar/envoy-proxy-benefits-communication-security-performance.jpg" />
</Frame>

You can install Envoy directly on Linux, macOS, or deploy it in Kubernetes (for example, via Helm charts bundled with many service-mesh installations). Managing many Envoy instances manually across a cluster is operationally expensive, which is why control planes such as [Istio](https://learn.kodekloud.com/user/courses/istio-service-mesh) exist — they handle injection, configuration, certificate rotation, and policy distribution at scale.

Example installation commands (Debian/Ubuntu and macOS):

```bash theme={null}
# Linux (Debian/Ubuntu)
sudo mkdir -p /etc/apt/keyrings
wget -O- https://apt.envoyproxy.io/signing.key | sudo gpg --dearmor -o /etc/apt/keyrings/envoy-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/envoy-keyring.gpg] https://apt.envoyproxy.io/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/envoy.list
sudo apt-get update
sudo apt-get install -y envoy
envoy --version

# macOS (Homebrew)
brew update
brew install envoy
```

Managing individual proxies for every workload can become complex. Service meshes provide a control plane to inject, configure, and manage Envoy sidecars across a cluster, reducing operational overhead and standardizing security, routing, and observability.

Links and references

* [Istio — Service Mesh Course](https://learn.kodekloud.com/user/courses/istio-service-mesh)
* [Envoy Proxy (official)](https://www.envoyproxy.io/)
* [Linkerd](https://linkerd.io/)
* [Traefik Mesh / Traefik Proxy](https://traefik.io/)
* [HAProxy](https://www.haproxy.org/)
* [NGINX course](https://learn.kodekloud.com/user/courses/nginx-for-beginners)
* [Helm course](https://learn.kodekloud.com/user/courses/helm-for-beginners)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/istio-certified-associate/module/da4579eb-7769-4ab9-a0e8-b81f70a12978/lesson/dc89929f-2873-4397-8cc5-9fab62003c1f" />
</CardGroup>
