Chapter 3 of 47 · Foundations

Pods: the most important word

If you remember only one Kubernetes word for now, make it Pod. Kubernetes does not manage containers directly. It manages Pods, and Pods hold your containers.

What a Pod is

A Pod is the smallest thing Kubernetes can run. Usually it holds exactly one application container.

What you run
DockerContainer
KubernetesPod → Container

Inside a Pod

Why the extra wrapper? Because the Pod is where Kubernetes attaches the things a container needs to live in a cluster. Click each part.

Parts of a Pod POD posts-7f9c Containerimage: micro-posts NetworkIP 10.0.1.17 Storagevolumes LifecyclePending → Running Everything in the dashed box lives and dies together

Container

Your application: the same container you ran with Docker, started from the same image. The Pod wraps it; it does not change it.

So a Pod gives your container networking, storage, a lifecycle, and a way to group containers that must run side by side.

One container or several?

A Pod with one containerPodpostslistens on :4000

This is what you will write 95% of the time: 1 Pod, 1 container. Need more copies? Make more Pods, not more containers in one Pod.

Your micro-posts as a Pod

Earlier you ran the posts service with Docker:

$ docker run -d \
    --name posts-container \
    -p 4000:4000 \
    micro-posts

Docker gives you

Container
└── micro-posts

Kubernetes gives you

Pod
└── micro-posts container

Same image, same app. Kubernetes simply manages the Pod around it. (You will write the YAML for this in a later chapter; for now the picture is enough.)

Why not create Pods yourself?

Suppose you want 3 copies of posts, so you create 3 Pods by hand. Now crash one:

It stays dead. A Pod on its own has no manager: nobody remembers that you wanted 3. You would have to notice and create another one yourself. Not good.

That is why we normally do not create Pods directly. We create a Deployment, which creates the Pods for us and keeps the right number running. That is the next chapter.

Recap

Quick check

You need 4 copies of posts. Do you put 4 containers in one Pod, or make 4 Pods?
Show answer

4 Pods with 1 container each. Copies of an app go in separate Pods so they can run on different machines and fail independently. Multiple containers in one Pod are for a main app plus helpers.

Kubernetes Pods: common questions

What is the difference between a Pod and a container?

A container is your running application. A Pod is the Kubernetes wrapper around one or more containers that gives them a shared IP address, storage and a lifecycle.