What is meant by Pets vs. Cattle and why it is an important way to think of Kubernetes

You may have heard the term Pets vs. Cattle and wondered what it meant. Or perhaps this is the first time reading it and are wondering what in the world are you talking about. So the term is an analogy, but a very powerful one.

If you have a Pet you take care of it, you nurture it, you give it a cute name and all that. If you are a commercial farmer you have cattle, not pets, you don’t give them cute names and when it is time to process them you send them off and move on. Now if you are familiar with setting up a server you have inevitably provisioned the server, applied all of the patches, setup the networking, installed the software you need and all that. And if that server had been running for a few months and you have invested time into that server if there is an issue you are very reluctant to just get rid of it and start fresh because it took you hours to build it the first time and you probably did not document all the patches and tweaks. Well that server is a Pet – you love it and you are caring for it and the idea of scrapping it starting fresh is not appealing.

Contrast that with a commercial farmer where they have 100 head of cattle and their job is to feed them and keep them healthy and if they get something like mad cow disease – well you dispose of them and start fresh. That is Cattle – they serve a purpose and when that purpose is no longer needed you can get rid of them.

So that is a useful analogy when working with Kubernetes, you spin up a cluster and you apply your YAML and then you are on your way. If something goes wrong or you need to move it somewhere else, that is fine, you just get rid of it and start fresh. You don’t get attached to it, it just serves a purpose.

If you wish to learn about the history of the term – this post from Randy Bias is essential reading.