Day 51: DaemonSets and StatefulSets
When "identical, interchangeable replicas" isn't the right model
A DaemonSet ensures exactly one copy of a Pod runs on every (or every matching) node — used for node-level agents: log collectors, monitoring exporters, CNI plugins. Unlike a Deployment, you don't set a replica count; the count is implicitly "one per node."
A StatefulSet manages Pods that need a stable, unique identity and stable storage — each replica gets a predictable name (db-0, db-1, db-2, not random suffixes), its own PersistentVolumeClaim that follows it across rescheduling, and Pods are created/deleted in order. This is what you reach for when replicas are *not* interchangeable — a database cluster where each node has distinct data, not a stateless API where any replica can serve any request.
# Deployment pods — random suffixes, fully interchangeable
api-7d4b9c8f6-x2n4p
api-7d4b9c8f6-p8k2q
# StatefulSet pods — stable, ordinal identity
postgres-0
postgres-1
postgres-2Key terms
- DaemonSet
- Runs exactly one copy of a Pod on every matching node.
- StatefulSet
- Manages Pods needing stable identity and storage, created/deleted in order.
Why would you run a log-collecting agent as a DaemonSet rather than a Deployment?