StatefulSet vs Deployment and Replicaset

I understand that the difference between Deployment and Replicaset, is that a Replicaset once deployed, does not allow updating a change (Yaml) at the level of its deployed PODs. On the other hand, a Deployment does allow when updating the Deployment (Yaml), the automatic update of your emebebidos PODs.

But how does a StatefulSet differ from them?

Thank you.

You can see the detailed information in this video

  • Deployment - You specify a PersistentVolumeClaim that is shared by all pod replicas. In other words, shared volume.The backing storage obviously must have ReadWriteMany or ReadOnlyMany accessMode if you have more than one replica pod.
  • StatefulSet - You specify a volumeClaimTemplates so that each replica pod gets a unique PersistentVolumeClaim associated with it. In other words, no shared volume.Here, the backing storage can have ReadWriteOnce accessMode.StatefulSet is useful for running things in cluster e.g Hadoop cluster, MySQL cluster, where each node has its own storage.

Deployment is a resource to deploy a stateless application, if using a PVC, all replicas will be using the same Volume and none of it will have its own state.

Statefulsets is used for Stateful applications, each replica of the pod will have its own state, and will be using its own Volume.

I understand then that the big difference is that STATEFULSETS applies a ‘Stateful’ handling and that each ‘POD’ will handle its own ‘Volume’ (different data for each one). Likewise, I understand that since they do not manage a storage persist their information is deleted, it would be lost along with the Pod (STATEFULSETS could use Persisten Volume?).

In this case when the instances are duplicated, there will always be a Master Instance, which would be the only one where it could be Read & Write, the other instances would be Slaves, and only Read would be allowed. Likewise, if a New Instance is to be created, it would be of the Slave type and this would Clone one of the previous Slave instances.

I am right ?.

Thank you.