305-998-7702 | 415-800-2922 info@rx-m.com

Understand Multi-Container Pod Design Patterns

Learn how to put the latest open source technology into practice with hands-on training, delivered by industry experts, aligned to your desired business outcomes

A pod may run one or more containers. Multi-container pods are tightly coupled in that the containers are co-located, co-scheduled and the containers share the same networkuts, and ipc namespaces. There are three patterns of multi-container pods:

  • Sidecar – sidecar containers extend and enhance the “main” container in the pod. The diagram below shows a web server container that saves its logs to a shared filesystem. The log saving sidecar container sends the webserver’s logs to a log aggregator.

Ambassador – ambassador containers proxy a pod’s local connection to the outside world. The diagram shows a three-node Redis cluster (1, 2, 3). The ambassador container is a proxy that sends the appropriate reads and writes from the main application container to the Redis cluster. The main application container is configured to connect to a local Redis server since the two containers share the same uts namespace.


Adapter – adapter containers standardize and normalize output for remote monitoring systems that require standard data formats. The diagram below shows a monitoring adapter container running an agent that reads the main application’s data, processes it, then exports the normalized data to monitoring systems elsewhere in the network.


A multi-container pod is created by specifying one or more additional container entries in a pod manifest. Shown below is an example of a multi-container pod with an nginx main container and an fluent-bit container sidecar in yaml. The nginx container writes its logs to a file at /tmp/nginx/, which is shared between all containers in the pod. The Fluent-Bit container reads the file from the shared directory and outputs it to its own standard output.

apiVersion: v1
kind: Pod
  name: sidecar
  - name: nginx
    image: nginx:latest
    - name: shared-vol
      mountPath: /tmp/nginx/    
    - /bin/sh
    - -c
    - nginx -g 'daemon off;' > /tmp/nginx/nginx.log
  - name: adapter
    image: fluent/fluent-bit
    - /fluent-bit/bin/fluent-bit
    - -i
    - tail
    - -p
    - path=/nginx/nginx.log
    - -o
    - stdout
    - name: shared-vol
      mountPath: /nginx
  -  name: shared-vol
     emptyDir: {}
  restartPolicy: OnFailure

Learn more about multi-container pod patterns.