Video in progress
What is a Pod in Kubernetes and how does it differ from a container?
A Pod is the smallest unit Kubernetes manages. It holds one or more containers that share one IP, one network and common volumes.
📖 Answer
Kubernetes does not start a container directly, it creates a Pod. In most cases there is one container in the Pod: your Spring Boot application.
Sometimes there is a helper container next to it (a sidecar): a log shipper, a proxy. They talk to each other over localhost, because the network is shared.
An important property: a Pod is ephemeral. If the node goes down or the Pod crashes, Kubernetes creates a new one somewhere else, with a new name and a new IP. That is why:
- do not hard-wire to a Pod IP, go through a Service;
- do not write important data to the disk inside the Pod.
kubectl get pods -o wide # pods, their IPs and nodes
kubectl logs shop-api-7d9f-abcde
Creating a Pod by hand is rare. Usually a Deployment manages it.
Sign up to mark studied questions and save your progress.