Why did Kubernetes have to introduce the concept of the "pod"? To me, pods seem to behave just like containers (e.g. Docker). Is it solely because of replications? Then, what about deployments in Kubernetes? Deployments can declare replicas as well.
-
2But pods don't behave just like containers, starting with the fact that they allow a group of containers to be treated as a single unit. This opens up all sorts of possibilities for integration of things that always have to be scheduled together (e.g., sidecar containers that enable log collection, monitoring, metrics collections, service discovery and routing, etc). – larsks Aug 15 '21 at 20:47
1 Answers
Pods can have multiple containers sharing the same overall context. This makes them act like a logical host.
This can be super useful and can safely enable things like service meshes where each pod has an extra proxy container which can do things like provide transparent TLS, audits and monitoring, added ways to test services, etc. It is also useful to help offload logging from the main app, and for numerous other cases.
Many use cases also heavily benefit from init containers which can prepare the pod for something using a separate, short lived container. This helps keep your main containers clean, lean, and purpose built.
Having k8s coschedule these related containers within the same pod makes sense for management and resource usage purposes (e.g. create together, clean up together on failure, all can share one IP and refer to each other with local host, etc).

- 37,047
- 37
- 155
- 255