StatefulSets vs Deployments for stateless applications on Kubernetes

1/19/2020

I find tons of articles and documentation describing the advantages of StatefulSets over Deployments for stateful applications on Kubernetes. What I haven't been able to figure out is the opposite: the disadvantages of StatefulSets when compared to Deployments, in particular for stateless applications.

Could someone please explain why not simply always use StatefulSets for both stateful and stateless applications?

-- chrisvdb
kubernetes
kubernetes-deployment
kubernetes-statefulset

1 Answer

1/19/2020

The most basic difference is that you would get ability to persist pod level state with statefulsets. Using volumeClaimTemplates, each replica will get a unique PersistentVolumeClaim with statefulset whereas all replicas would share the PersistentVolumeClaim with a deployment. This comes at a cost of slow scale ups and scale downs for statefulsets.

Deployments also have cool features related to "deployment" like rolling update with maxSurge and maxUnavailable.

-- Shashank V
Source: StackOverflow