DEV Community

Cover image for Part-80: 🟢Kubernetes – Pods & Multi-Container Pods
Latchu@DevOps
Latchu@DevOps

Posted on

Part-80: 🟢Kubernetes – Pods & Multi-Container Pods

When working with Kubernetes, everything starts with Pods. They are the most basic building blocks in a Kubernetes cluster. Let’s break this down step by step.


🚀 Kubernetes – Pods

p1

  • The main goal of Kubernetes is to deploy applications inside containers on worker nodes.
  • But Kubernetes does not deploy containers directly on worker nodes.
  • Instead, containers are wrapped inside a special Kubernetes object called a Pod.

p2

👉 Key things to know about Pods:

  • A Pod is a single instance of an application.
  • A Pod is the smallest object you can create in Kubernetes.
  • Pods generally follow a one-to-one relationship with containers.
  • To scale up, you create more Pods. To scale down, you delete Pods.
  • You cannot run multiple containers of the same type in a Pod.

Example ❌: Running two NGINX containers inside the same Pod is not recommended.

p3

✅ So, think of a Pod as a “wrapper” that holds one containerized application instance.


🟢 Kubernetes – Multi-Container Pods

Sometimes, a Pod may need more than one container. This is called a Multi-Container Pod.

p4

👉 Rules for Multi-Container Pods:

  • You can have multiple containers in one Pod, but they should not be of the same kind.
  • Example: You can’t run two identical NGINX containers in one Pod, but you can run an NGINX + helper container together.

📦 Common Helper (Sidecar) Containers

Multi-Container Pods are often used with sidecar containers, which work alongside the main application container:

  • Data Pullers → Download data needed by the main container.
  • Data Pushers → Collect logs or data from the main container and push them elsewhere.
  • Proxies → Write static data using a helper container, then the main container serves it.

đź”— Communication Inside a Pod

  • Containers inside the same Pod share the same network space (they can talk to each other over localhost).
  • They also share the same storage volumes, making it easy to exchange files/data.

⚠️ Important Note

  • Multi-Container Pods are considered a rare use-case.
  • In most scenarios, you’ll work with single-container Pods, because that’s the core Kubernetes fundamental.

âś… Summary

  • Pod → Smallest Kubernetes object, usually runs one container.
  • Scaling → Add or remove Pods, not containers inside a Pod.
  • Multi-Container Pod → Used only when containers must work closely together (sidecars).
  • Communication → Containers inside the same Pod share network and storage.

Top comments (0)