Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Running Applications  ›  Lesson

Pods

Pods 12 minA pod is the smallest deployable unit, holding one or more containers that share an IP address and volumes and are scheduled together on one node.

Pods

Every workload in Kubernetes — a web server, a database, a nightly backup — ends up as pods. Understand the pod and every higher-level object becomes "a thing that makes pods".

The rule

A pod is one address shared by containers that live and die together.

A pod wraps one or more containers that:

  • share one IP address and port space, so they reach each other on localhost;
  • can share volumes (directories);
  • are always scheduled onto the same node and started and stopped as a unit.

Most pods hold one container. A second one is added only when it is a close helper — for example a sidecar that ships the main container's log files.

apiVersion: v1
kind: Pod
metadata:
  name: notes-web
  namespace: notes
  labels:
    app: notes-web
spec:
  containers:
    - name: web
      image: ghcr.io/example/notes-web:1.2
      ports:
        - containerPort: 8080

Pods are disposable. If the node under a pod fails, that pod is gone; a new pod with a new name and a new IP may replace it, but only if something higher up — a Deployment, for instance — asks for one. A bare pod created from the file above is not replaced by anyone.

A pod's status tells its story: Pending (waiting for a node or an image), Running, Succeeded, Failed, and the famous CrashLoopBackOff — the container keeps exiting and Kubernetes waits longer before each restart.

The shortcut

To decide whether two containers belong in one pod, ask: "Must they share a machine and always scale together?" If yes, one pod. If they could live apart, two pods.

notes-web, notes-db and a log shipperStep 1 of 3
  1. notes-web and notes-db

    The database scales differently and must outlive web restarts. They can live apart: separate pods.

The trap is packing a whole app (web plus database) into one pod. Scaling the web tier would then clone the database too.

Drills

Answer fast — trust the rule.

quick drill

How do two containers in the same pod reach each other?

quick drill

A bare pod (no Deployment) is on a node that dies. What happens?

quick drill

Which pair belongs in one pod?

quick drill

A pod shows CrashLoopBackOff. What does that mean?

Remember

  • A pod is one address shared by containers that live and die together.
  • Same pod only if they must share a machine and scale together.
  • Trap: bare pods are not replaced, and web plus database in one pod scale wrongly.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainOne pod or two?

Explain why notes-web and notes-db should run in separate pods, but notes-web and a log-shipping helper should share one pod.