Kubernetes and Cloud Native Associate - KCNA

Container Orchestration Service Mesh

Sidecars

In this article, we explore the role of sidecars in service meshes with a special emphasis on the Istio Service Mesh. Before diving into Istio, it's essential to understand the concept of sidecars and their significance in Kubernetes deployments.

Prerequisite Information

Before proceeding, ensure you are familiar with the basics of Kubernetes, including Pods, containers, and networking.

Sidecars are additional containers that run alongside the main application container within a Kubernetes Pod. They are analogous to the small passenger cabins attached to motorcycles—complementary, yet distinct in purpose. In Kubernetes, while the primary container executes the core business logic of the application, sidecar containers handle auxiliary tasks such as log shipping, monitoring, file loading, or proxying. Importantly, sidecars share the same volumes and network namespace as the main container, ensuring seamless communication and resource sharing.

The image illustrates a Kubernetes pod with a main container and a sidecar container, highlighting functions like file loading, log shipping, and monitoring.

This approach of separating non-business functions from the primary application logic promotes improved modularity, maintainability, and scalability of your application architecture.

Below is a simple example of a Kubernetes Pod definition that demonstrates the use of a sidecar container. In this configuration, the main container runs an NGINX image, while an additional container based on the Fluentd image acts as the sidecar, responsible for shipping logs from the main application to a centralized logging system.

containers:
- name: nginx-container
  image: nginx
  volumeMounts:
  - name: shared-data
    mountPath: /usr/share/nginx/html
- name: sidecar-container
  image: fluent/fluentd
  volumeMounts:
  - name: shared-data
    mountPath: /pod-data

Next, we will delve into Envoy and examine its role within service meshes, highlighting how it interacts with sidecar patterns to enhance traffic management and security in distributed systems.

Watch Video

Watch video content

Previous
Kubernetes Services
Next
Envoy