Why StatefulSets

Why Stateful Workloads Need a Different Controller

A Deployment treats its Pods as interchangeable: random name suffixes, any order, a shared template with no per-Pod storage, and a rollout that starts a new Pod before stopping an old one. That suits BookNest's API. A database, message broker or etcd 137,357 member is not interchangeable: replica 0 may be the primary, each member keeps its own data, peers must find each other by name, and two copies must never write to the same files at once.

Deployments and StatefulSets compared
Property Deployment StatefulSet
Pod names api-7bf856ff84-xn4xm postgres-0, postgres-1
Network identity Service IP only Stable DNS name per Pod
Storage Shared or none One claim per Pod, kept
Start and stop Any order, in parallel Ordered by index
Rolling update Surge, new before old Highest index first, one at a time

A StatefulSet does not make an application highly available. It gives each Pod an identity that survives rescheduling; replication, failover and backups remain the application's job, or an operator's (Operators and CRDs).