StatefulSets
StatefulSets are used to manage stateful replicas. Similar to a Deployment, a StatefulSet creates and manages the specified number of Pod replicas from an identical Pod template. However, where StatefulSets differ from Deployments is that they maintain a unique identity for each of their Pods. So, even if all the Pods are of identical specs, they are not interchangeable. Each of the Pods has a sticky identity that can be used by the application code to manage the state of the application on a particular Pod. For a StatefulSet with n replicas, each Pod is assigned a unique integer ordinal between 0 and n – 1. The names of the Pods reflect the integer identity assigned to them. When a StatefulSet is created, all the Pods are created in the order of their integer ordinal.
Each of the Pods managed by a StatefulSet will persist their sticky identity (integer ordinal) even if the Pod restarts. For example, if a particular Pod crashes or is deleted, a new Pod will be...