Kubernetes: Deployment vs StatefulSet vs DaemonSet?
asked 4 months ago623 viewsen
When do I use each of these workload types? I'm deploying a web API, a PostgreSQL database and a log collector.
AI diagnosis
AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.
1 Answer
- Deployment: for stateless apps. Pods are interchangeable and can be killed, rescheduled and scaled freely. → your web API. - StatefulSet: for apps needing stable identity and storage. Each pod gets a stable name (db-0, db-1) and its own PersistentVolume, and pods start and stop in order. → databases, Kafka, Elasticsearch. - DaemonSet: runs exactly one pod per node. → log collectors (Fluent Bit), monitoring agents, CNI plugins.
Practical advice on the database: unless you have strong Kubernetes operations experience, use a managed database (RDS, Cloud SQL, Azure Database, Supabase, Neon), or an operator like CloudNativePG if it must run in-cluster. Running Postgres on a raw StatefulSet means handling backups, failover and upgrades yourself.
Sign in to tell others whether this worked.
Sign in and verify your email to post an answer.