← All posts
2 min read

Pods: the atom of Kubernetes

#kubernetes#devops

Part 2 of Kubernetes from Zero. Time to touch the cluster.

What is a Pod?

A Pod is the smallest thing Kubernetes schedules — one or more containers that share a network namespace and storage. 99% of the time, a Pod is just one container plus the plumbing around it.

Why not schedule containers directly? Because some things belong glued together: an app and its log shipper, a service and its proxy sidecar. Containers in a Pod see each other on localhost.

Run your first Pod

With a local cluster (kind, minikube, or Docker Desktop):

kubectl run hello --image=nginx --port=80
kubectl get pods
kubectl describe pod hello   # the debugging goldmine
kubectl logs hello
kubectl delete pod hello

The YAML version

The imperative commands above are for exploring. Real work is declarative:

pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: hello
  labels:
    app: hello
spec:
  containers:
    - name: web
      image: nginx:1.27
      ports:
        - containerPort: 80
kubectl apply -f pod.yaml

The catch

Delete the node this Pod runs on and the Pod is gone — nothing recreates it. Bare Pods are cattle with no herder. That's why you'll almost never create Pods directly.

In part 3, we fix that with Deployments — and expose them to traffic with Services.