A database is a stateful component and has to be treated differently to stateless components, such as our web component. We have discussed the difference between stateful and stateless components in a distributed application architecture in detail in Chapter 6, Distributed Application Architecture, and Chapter 9, Orchestrators.
Kubernetes has defined a special type of ReplicaSet object for stateful components. The object is called a StatefulSet. Let's use this kind of object to deploy our database. The definition can be found in the labs/ch13/db-stateful-set.yaml file. The details are as follows: