Kubernetes Deployments vs StatefulSets

0
946

Question:

I’ve been doing a lot of digging on Kubernetes, and I’m liking what I see a lot! One thing I’ve been unable to get a clear idea about is what the exact distinctions are between the Deployment and StatefulSet resources and in which scenarios would you use each (or is one generally preferred over the other).

Any experiences people can share would be awesome!!

Answer:

Deployments and ReplicationControllers are meant for stateless usage and are rather lightweight. StatefulSets are used when state has to be persisted. Therefore the latter use volumeClaimTemplates / claims on persistent volumes to ensure they can keep the state across component restarts.

So if your application is stateful or if you want to deploy stateful storage on top of Kubernetes use a StatefulSet.

If your application is stateless or if state can be built up from backend-systems during the start then use Deployments.

Further details about running stateful application can be found in 2016 kubernetes’ blog entry about stateful applications

LEAVE A REPLY

Please enter your comment!
Please enter your name here