DEV Community

Cover image for Deployment vs StatefulSet | Kubernetes StatefulSet simply explained
TechWorld with Nana
TechWorld with Nana

Posted on

5 2

Deployment vs StatefulSet | Kubernetes StatefulSet simply explained

While StatefulSet is used for stateful applications, like databases, Deployment component is used to deploy stateless applications. Many web apps fall into this category.

So the question is:

What is the difference between Deployment and StatefulSet components? πŸ€”

Deployment vs StatefulSet component
Pods deployed by Deployment are identical and interchangeable, created in random order with random hashes in their Pod names.

In contrast to that, the Pods deployed by StatefulSet component are NOT identical and deployment is more complex. They each have their own sticky identity, which they keep between restarts and each can be addressed individually. Thus, they can't be created or deleted at the same time or in any order.

How these identities are created and why it's so important, I explain in detail in the below video 🎬.

You can find the full video here:


I'm happy to connect with you on πŸ™‚

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (3)

Collapse
 
jiayanguo profile image
jguo β€’

Thanks for sharing. It's very helpful. I was confused why statefulset is required.

It's used to create differentiate pods. Like master-slaves, leader-followers.

Collapse
 
techworld_with_nana profile image
TechWorld with Nana β€’

Thanks a lot, glad it's helpful :)

Collapse
 
murrengan profile image
Murrengan β€’

Ths!

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more