Differences Between Deployment and StatefulSet
StatefulSet |
Deployment |
---|---|
StatefulSets are Kubernetes component that is used specifically for stateful applications. |
Deployment is used to deploy stateless applications. |
In StatefulSets, the pods get created as well as deleted in a specific order |
In Deployment, all pods are created parallelly. |
When we scale down StatefulSets, the last pod gets deleted |
When we scale down a deployment a random pod is picked up and deleted |
A sticky and predictable name is assigned to the pods |
A random name is assigned to the pods. |
Each pod uses its own persistent volume (like we saw in the tutorial.) |
All the pods use the same persistent volume |
Kubernetes StatefulSets: Running Stateful Applications in Containers
StatefulSets are Kubernetes components that are used specifically for deploying stateful applications. In Kubernetes on the basis on methods of deploying. There are two types of applications – Stateful applications and stateless applications. Therefore, There are two ways for deploying an application on Kubernetes – through Deployment (for deploying stateless applications) and through StatefulSets (for deploying stateful applications).
Applications that maintain any form of persistent state or data are called stateful applications. Most of the database applications that we build like MySQL and MongoDB are stateful applications. The basic point of difference between a stateful and a stateless application is the need of persistent storage. Stateful applications requires a persistent storage while stateless applications do not have a need to store data, therefore they don’t require any persistent storage.