Thuta Learning
BasicDevOpsintermediate

Pods — The Basic Unit

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Pods — The Basic Unit without any of the intimidation
  • Get comfortable running kubectl commands and YAML yourself
  • Apply this concept right away in a real project

Take a moment to think about this

In Docker, you run a 'container' directly — in Kubernetes, you never run a container directly, it's always wrapped inside a Pod. A Pod can hold a single container (the most common pattern) or a small handful of closely related containers (for example, a main app plus a logging sidecar). Containers within a Pod share network (IP address) and storage — think of it like 'rooms in the same house'.

Let's connect this to a real scenario

You define a Pod with a YAML file and create it with `kubectl apply -f pod.yaml`. If a Pod crashes (or its node dies), Kubernetes can recreate it — but that's not the old Pod 'coming back to life', it's a brand-new Pod (with a new IP address). That's exactly why, in production, you don't run Pods directly but through a Deployment (next lesson) instead.

Let's look at it together

yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-first-pod
spec:
  containers:
    - name: web
      image: nginx:latest
      ports:
        - containerPort: 80
You should see
$ kubectl apply -f pod.yaml
pod/my-first-pod created

$ kubectl get pods
NAME            READY   STATUS    RESTARTS   AGE
my-first-pod    1/1     Running   0          10s

5-minute try-it

Save the pod.yaml above as a file and run `kubectl apply -f pod.yaml` — check with `kubectl get pods` until the status becomes Running.

A quick word of caution

Creating a Pod directly with `kubectl apply -f pod.yaml` is fine for learning — in production, run it through a Deployment (which includes self-healing).

Easy traps

  • Running production apps as bare Pods — if a Pod dies, nothing recreates it (you need a Deployment for auto-recreation)
  • Thinking each container inside a Pod is like a 'separate server' — actually they're more like 'rooms in the same house', sharing IP and storage

Now try it yourself

Save the pod.yaml above as a file and run `kubectl apply -f pod.yaml` — check with `kubectl get pods` until the status becomes Running.

You'll know it worked when: $ kubectl apply -f pod.yaml pod/my-first-pod created $ kubectl get pods NAME READY STATUS RESTARTS AGE my-first-pod 1/1 Running 0 10s

Pods — The Basic Unit | Thuta Learning