Chapter 8. Multi-Container Pods
Chapter 5 explained how to manage single-container Pods. That’s the norm, as you’ll want to run a microservice inside of a single Pod to reinforce separation of concerns and increase cohesion. Technically, a Pod allows you to configure and run multiple containers.
In this chapter, we’ll discuss the need for multi-container Pods, their relevant use cases, and the design patterns that have emerged in the Kubernetes community. The exam outline specifically mentions prominent design patterns: the init container, the sidecar container, and others. We’ll get a good grasp of their application with the help of representative examples.
Working with Multiple Containers in a Pod
Especially for Kubernetes beginners, how to appropriately design a Pod isn’t necessarily apparent. If you read the Kubernetes user documentation and tutorials on the internet, you’ll quickly discover that you can create a Pod that runs multiple containers at the same time. The question then arises: “Should I deploy my microservices stack to a single Pod with multiple containers, or should I create multiple Pods, each running a single microservice?” The short answer is to operate a single microservice per Pod. This modus operandi promotes a decentralized, decoupled, and distributed architecture. Furthermore, it helps with rolling out new ...