CONTAINERS / A CONCEPT NOTE

StatefulSets & Operators

running databases in clusters

~75 sec read

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

  1. Stateful order

    launches pod-0 first, waits for it to report healthy, then launches pod-1.

  2. Storage mount

    each pod mounts its own dedicated persistent volume (PVC) matching its index number.

  3. Failover event

    pod-1 crashes. StatefulSet recreates pod-1, linking it back to its original storage disk.

  4. 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.

EXAMPLE 01 · REFERENCE

list active StatefulSet controllers

kubectl get statefulset

EXAMPLE 02 · REFERENCE

see volume claims bound to stateful pods

kubectl get pvc

Explore command anatomy in the CLI lab