We could look at the sidecar container as an application plugin, that adds functionalities to the the main application.


Containers are reusable units that usually do one specific task. We could compare them to processes.

To be able to add new functionalities to our container, without the need to rewrite a new one that would include the new functions, we use sidecar containers that have these new characteristics.

Pods allow us to have more than one container in a single unit. We could run a container - running the main application - along with a sidecar container - with the added capabilities - inside the same pod.

Below we have a debian image running as a sidecar container to the nginx image that is running as the main container.

The debian container could be running any programs that "helps" the nginx server - logging, database, ... -.



The emptyDir is an empty directory on the storage medium attached to the node hosting the pod
All the containers of the pod could write to or read from the emptyDir volume.

The volumeMounts are the paths on which the volume is mounted inside each container.

Remark:

When we run a command like " kubectl exec",  it runs on the main container, not the sidecar container.

The connection between the containers is done through IPC, the localhost interface, ...
Brando Sabatini and Ikbal C ©. Powered by Blogger.