Skip to content
tezvyn:

Kubernetes Pods: The Atomic Unit of Deployment

Source: kubernetes.ioMediumHow cards are made

Kubernetes Pods: The Atomic Unit of Deployment

A Kubernetes Pod is the atomic unit of deployment, a logical host for containers sharing a network and storage. This is ideal for co-locating a main app with a helper "sidecar" container. The footgun: a Pod is not a container; you scale by adding more.

Why it exists

Containers are designed to run a single process, but applications often require multiple cooperating processes. Kubernetes needed a higher-level construct to group these processes, providing a shared execution environment without forcing developers to merge multiple concerns into a single container image. The Pod provides this co-location and shared context as the atomic unit of scheduling.

The mental model

Think of a Pod as a small, logical host machine dedicated to a single application instance. The containers inside are like processes running on that machine. They all share the same network interface (the same IP address and port space) and can share storage volumes mounted to the Pod. This makes them tightly coupled, but isolated from containers in other Pods.

How it works

Kubernetes manages Pods, not containers directly. When you define a Pod, you specify which container images to run. The scheduler assigns the Pod to a healthy Node. The kubelet on that Node then instructs the container runtime (like containerd) to pull the images and run the containers. All containers in a Pod are always co-located and co-scheduled on the same machine and share a lifecycle: when the Pod is created, its containers are started; when it's destroyed, all its containers are terminated.

When to use it

The primary use case is running a single containerized application; the "one container per Pod" model is the most common. Use multiple containers in a single Pod only when they are very tightly coupled. A classic example is the "sidecar" pattern: a main application container with a helper container for tasks like logging, monitoring, or acting as a network proxy. These helpers augment the main application without being part of its codebase.

When not to use it

Do not group unrelated applications into a single Pod, like your web server and database. Pods are scaled as a unit; if the web server needs 10 replicas and the database needs 2, they must be in separate Pods managed by separate controllers (like Deployments). Pods are also ephemeral and can be replaced at any time. Never rely on a Pod's IP address; use a Kubernetes Service for a stable endpoint.

One canonical example

A web server container serves traffic on port 80. A second "sidecar" container in the same Pod reads the web server's log files from a shared volume and forwards them to a central logging service. The two containers can communicate as if they were on the same host. The sidecar can scrape metrics from the web server by making a request to localhost:8080/metrics.

Interview question

What is the primary reason for grouping multiple containers into a single Kubernetes Pod?

  • a.To co-locate tightly coupled processes that need to share a network namespace and lifecycle.Correct
  • b.To enable independent scaling of each container based on its specific workload.
  • c.To consolidate unrelated applications onto a single Node for better resource utilization.
  • d.To provide a stable, persistent network identity for each container within the Pod.
Why?

The card emphasizes that multiple containers are used in a Pod when they are "very tightly coupled" and need to "share the same network interface" and "share a lifecycle." This is exemplified by the sidecar pattern. Option B is incorrect because Pods are scaled as a unit, not individual containers within them.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles