Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Same cluster, different replica requirements
Why can a replacement pod be a clean swap for an API, but not for this database configuration? The API replicas are equivalent; the database replicas need stable names and individual volumes. Those requirements shape how Kubernetes replaces them.
Deployment: replicas are interchangeable
A Deployment keeps the API at its desired replica count by maintaining API pod A and API pod B. If one fails, Kubernetes creates a replacement, but that pod doesn't need the same name; the API replicas are interchangeable because they serve equivalent requests.
StatefulSet: each replica has an identity
A StatefulSet gives each replica a stable ordinal identity. If database pod db-0 disappears, its replacement is named db-0 again, unlike an API replacement whose name can change while its role stays interchangeable. That identity doesn’t guarantee a stable pod IP.
Each database replica keeps its own volume
db-0 mounts Volume 0, and db-1 mounts Volume 1, so each replica has its own storage. If a pod is replaced, its volume claim can remain and reconnect it to the associated volume, provided that storage is available.
The API's replacement pod can have a new name, but each database replica needs its old name and volume. Which controller fits the database?
Let's think this through. The API's replacement pod can have a new name, but each database replica needs its old name and volume. Which controller fits the database? A: Deployment, because both workloads use pods. B: StatefulSet, because replica identity and storage must persist. C: Deployment, because persistent storage requires it. Choose an answer, or just think it through.
I'll explain in a moment.
- Deployment, because both workloads use pods
- StatefulSet, because replica identity and storage must persist
- Deployment, because persistent storage requires it
The API's replacement pod can have a new name, but each database replica needs its old name and volume. Which controller fits the database?
The answer is B: StatefulSet, because replica identity and storage must persist. A StatefulSet gives each replica a stable ordinal identity and can associate it with its own persistent volume claim. A Deployment can use persistent storage, but it does not preserve each replacement pod's individual identity.
- Deployment, because both workloads use pods
- StatefulSet, because replica identity and storage must persist
- Deployment, because persistent storage requires it
Rollouts and scaling differ
The Deployment updates equivalent API replicas under rollout settings that govern availability. The StatefulSet updates numbered database pods in order, and by default creates and terminates them in order too. Its lifecycle respects each replica’s ordinal identity.
Important limits
Persistent storage doesn't automatically call for a StatefulSet; Deployments can use persistent volumes too. Neither controller replicates database data, and whether a volume survives failure depends on the underlying storage system.
- Persistent storage alone is not decisive
- Controllers do not replicate database data
- Storage durability depends on infrastructure
Choose by replica requirements
The API’s replicas are interchangeable, so a Deployment can replace a failed pod with any new replica. This database requires db-0 and db-1 to keep their identities and volume associations, so use a StatefulSet.
Interchangeable pods or persistent identities?
Choose by replica needs: interchangeable pods favor Deployments; required stable identities and volumes favor StatefulSets.





