Wednesday, September 2, 2026

Multi-Container Pods

 

What is a Multi-Container Pod?


A Multi-Container Pod is a Pod that contains more than one container. These containers run together in the same Pod and share the same network and storage.



Why Use Multi-Container Pods?


Sometimes an application needs a helper container which is also Sidecar Container for tasks such as:


Log collection

Monitoring

Proxy service

Data synchronization


Instead of running them separately, both containers can run inside the same Pod.



Example:


Pod

├── Nginx Application Container (Main Application)

└── BusyBox Logging Container (Log Collector)



Both containers:


Containers work closely together.

Share the same IP address

Can communicate using localhost

Can share volumes (storage)




Multi-Container Pod YAML



apiVersion: v1

kind: Pod

metadata:

  name: multi-container-pod


spec:

  containers:

  - name: nginx

    image: nginx


  - name: busybox

    image: busybox

    command: ["sh", "-c", "while true; do echo Hello; sleep 10; done"]




Create the Pod - kubectl apply -f pod.yaml

Verify - kubectl get pods



No comments:

Post a Comment

testing