StatefulSets allow stateful applications to be managed by a Kubernetes controller. Since pods are stateless, we need a higher level concept to allow us to provide consistent pod naming and storage.

They're ideal for workloads involving storage, such as database and cache servers.

apiVersion: v1
kind: StatefulSet
    name: my-statefulset
spec: x

Differences to Deployments

Unlike Deployments, which are designed for deploying stateless applications, StatefulSets assign each pod a "sticky" identity (an ordinal index, starting from zero). This identity persists across rescheduling. The pod's DNS name is derived from this identity.