A database is a stateful component and has to be treated differently to stateless components, such as our web component. We discussed the difference between stateful and stateless components in a distributed application architecture in detail in Chapter 9, Distributed Application Architecture, and Chapter 12, 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 ~fod/ch16/db-stateful-set.yaml file. The details are as follows: