What is the difference between a StatefulSet and a Deployment?
Use a Deployment for stateless workloads (web servers, APIs) where any Pod is interchangeable. Use a StatefulSet for stateful workloads like databases that need:
- Stable, predictable network identities (pod-0, pod-1, etc.)
- Ordered, graceful deployment and scaling
- Stable persistent storage linked to each pod individually
Common examples: Kafka, ZooKeeper, Cassandra, PostgreSQL replicas.