I began this blog series by explaining the differences between virtual machines and containers. Next I discussed the importance of running containers at scale. In this blog, I’ll discuss immutable infrastructure.
To begin with, the move to containers has made it possible to run pre-built-and-configured components on every deployment. More specifically, on every deployment, the old components are replaced. This is a break in the previous method of using a tools like Chef to create and then update systems on a recurring basis.
This is possible with containers because they are fast to deploy because of their smaller size, and the innate quality that they will run the same way on any environment. This versus provisioning a bare-metal or virtual machine that has a longer lifespan and the cost in terms of time in particular makes updates preferable. This is an improvement on the traditional pattern and makes life easier!
Kubernetes takes this to the next logical step by providing a platform that is able to fully utilize running containers at scale and are run, scaled-up, scaled-down, or destroyed on demand without the concern of “how to I modify these hosts with X”. This puts to use the whole concept of immutable infrastructure at scale.
Another concept that helps explain immutable infrastructure is the difference between “pets” and “cattle”.
Pets vs Cattle
A “pet” would be a legacy pattern and would consist of either bare-metal virtual machines that have a long life-span and a specialized configuration that can’t be lost. They are also defined by not running in large numbers because of their specialized nature. Pets get special attention, are maintained, updated, and not restarted often.
On the other hand, “cattle” are more generalized systems like containers (or in some cases virtual machines) that can easily be replaced and would require much time to run and be in service. Cattle are disposable because they can easily be replaced, and aren’t known for being updated.
Kubernetes pods run “cattle”, though there is still a need for more long-lived containers that are “cared” for as pets, which StatefulSets lend themselves to (another blog post!)
In my next post I’ll dive deeper into what Kubernetes is and share some key terminology and examples.