StatefulSetsIntermediate
1Question 1 of 1
yamlWhat is a StatefulSet and when should you use it over a Deployment?
Explanation & Concept
StatefulSets are used for stateful applications (databases, Kafka, ZooKeeper) that require: 1. Stable, unique network identifiers (e.g. `web-0`, `web-1`). 2. Stable persistent storage tied to each specific pod ordinal. 3. Ordered, graceful deployment and scaling.
Code Example
yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-cluster
spec:
serviceName: "redis"
replicas: 3
# Pods created strictly in order: redis-0, redis-1, redis-2How It Works & Key Takeaways
If `redis-1` fails, Kubernetes restarts it with the exact same hostname and re-attaches its specific persistent storage volume.
Mock Test · 1 Questions · Optional
Ready for Rolling Updates & Rollbacks?
Take a quick test to evaluate yourself, or move straight to the next module.
Intermediate1 questions