CONTAINERS / A CONCEPT NOTE
StatefulSets & Operators
running databases in clusters
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
StatefulSets manage stateful workloads (like databases) by guaranteeing persistent identity names (pod-0, pod-1) and stable storage. Operators extend the API to automate database failovers.
02 / FOLLOW THE MECHANISM
How stateful rollouts flow
Stateful order
launches pod-0 first, waits for it to report healthy, then launches pod-1.
Storage mount
each pod mounts its own dedicated persistent volume (PVC) matching its index number.
Failover event
pod-1 crashes. StatefulSet recreates pod-1, linking it back to its original storage disk.
Operator loop
special controller monitors status, automatically electing a new database primary if pod-0 dies.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
list active StatefulSet controllers
kubectl get statefulsetsee volume claims bound to stateful pods
kubectl get pvc05 / CHECK YOURSELF
Could you explain StatefulSets & Operators to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.