Understanding StatefulSets
In Figure 14.1, we can see that a StatefulSet is invoked to be able to manage pod life cycles. A StatefulSet (in older versions of Kubernetes, this was called a PetSet) operates very similarly to a Deployment in that we provide a pod template of what we want to run and how many instances of it we want to run. What differs between a StatefulSet and a Deployment is the following:
- A clear naming scheme that can be depended upon by pods in DNS queries:
This means that in the preceding diagram when we name a StatefulSet
mysql
, the first pod in that StatefulSet will always bemysql-0
. This is unlike a traditional deployment where pod IDs are assigned randomly. It also means that if you had a pod namedmysql-2
and it crashed, it would be resurrected on the cluster using exactly the same name. - A clearly ordered way in which updates must proceed:
Depending on the update strategy in this StatefulSet, each pod will be taken down in a very specific order. So...