Difficulty: Beginner
What is a Pod in Kubernetes, and why does Kubernetes schedule Pods instead of individual containers?
A Pod is the smallest deployable unit in Kubernetes: a group of one or more containers that are always scheduled onto the same node and share a network namespace, an IP address and optionally storage volumes. Kubernetes schedules Pods rather than raw containers so that tightly coupled helpers (like a log shipper or proxy) can live next to the main app and behave like processes on one machine.
localhost, so two containers in the same Pod cannot both bind port 8080.emptyDir, can be mounted by several containers to exchange files.shareProcessNamespace: true.Under the hood the kubelet creates a tiny "pause" (sandbox) container that holds the network namespace, and the app containers join it.
A container is meant to run one process. Real services often need helpers that must share the same network and disk: an Envoy proxy for a service mesh, a Fluent Bit sidecar shipping logs, or a process that refreshes TLS certificates. If these were separate scheduling units, they could land on different nodes and could not talk over localhost. The Pod gives Kubernetes a single "logical host" to schedule, monitor and scale. It also lets Kubernetes stay runtime-agnostic: the Pod spec is the same whether the node uses containerd or CRI-O.
| Pattern | Example | Purpose |
|---|---|---|
| Single container | A Node.js API | The most common case, by far |
| Sidecar | Envoy, Fluent Bit | Adds networking or logging next to the app |
| Init container | Wait for DB, run migrations | Runs to completion before app containers start |
| Ambassador / adapter | Local proxy to Redis | Simplifies how the app reaches external systems |
Since Kubernetes v1.29 (beta, on by default) and GA in v1.33, native sidecars are declared as init containers with restartPolicy: Always. They start before the app and keep running, which fixes old problems such as Jobs never finishing because a sidecar kept running.
apiVersion: v1
kind: Pod
metadata:
name: orders-api
labels:
app: orders
spec:
initContainers:
- name: log-shipper # native sidecar (v1.29+)
image: fluent/fluent-bit:3.1
restartPolicy: Always # keeps running alongside the app
volumeMounts:
- name: logs
mountPath: /var/log/app
containers:
- name: api
image: ghcr.io/acme/orders-api:1.4.2
ports:
- containerPort: 8080
volumeMounts:
- name: logs
mountPath: /var/log/app # app writes logs here
volumes:
- name: logs
emptyDir: {}
Both containers mount the same emptyDir, so the sidecar can read the files the API writes. They also share the Pod IP, so the sidecar could reach the API at localhost:8080.
Pod, Sidecar Container, Init Container, Shared Network Namespace, Ephemeral IP