Session 1: the pod is not a container
The pod is the atomic unit of Kubernetes. The most common early misconception is that a pod equals one container. It doesn’t. A pod is one or more containers that share network, storage, and lifecycle. Containers inside a pod always land on the same node, share the same IP, and can talk to each other on localhost.
Most pods have one container. Some have two. The second container is usually a “sidecar” (a log shipper, a proxy, a metrics exporter) or an “init container” that runs setup before the main container starts.
Why this abstraction exists: Kubernetes wanted a unit that can hold tightly coupled processes without giving up per-process resource limits or lifecycle. A pod says “these things always live and die together.”
kubectl commands I ran today:
kubectl run demo --image=nginx(creates a pod directly)kubectl get pods(lists pods in the current namespace)kubectl describe pod demo(details, including the container list)kubectl logs demo(logs from the single container)kubectl exec -it demo -- /bin/sh(shell inside the container)kubectl delete pod demo(cleanup)
Things I noticed:
- The pod IP shown in
describebelongs to the pod, not the container. If the pod had two containers, they would share it. - The Events section at the bottom of
describeshows the lifecycle: Scheduled → Pulling image → Pulled → Created → Started. - Deleting the pod does not restart it. Nothing was watching to keep it alive. That is a job for a Deployment, which comes tomorrow.
Next: why you almost never create a pod directly.