Stateful sets:

Stateful sets is a kubernetes component used for stateful applications like databases for example.

Stateful applications:

Stateful applications is any application that stores information about its state. Any new requests to this application will be processed based on previous (stored) data.

Stateful applications are deployed using stateful deployment components in a YAML file which allows us to have replicas of stateful pods and configures the persistent storage for them.

Stateless pods in a group are identical, stateless pods are not, they have different states


Example:

We have three database pods "replicas", these replicas are not identical, each one of them has a unique identity.

The "replicas" are created using the same configuration file, but they are not the same, because their states are not identical.


DB-1, DB-2 and DB-3 are the unique identities of the pods.

Stateful pods get created in an ascending order, for example, if another pod gets added it will get the DB-4 identifier.

When a new pod is added it copies the data from the previous pod, DB-4 replicates the data from DB-3.


Stateful pods get deleted in reverse order, DB-3 gets deleted first them DB-2 then DB-1.

Master and Slave pod:

As you can see in the diagram above, we have one master pod that can read and write and slave pods that can only read data.

The storage is not tied to the pod, if the pod crashes and gets re-deployed, storage gets linked to the new pod so it can retrieve its state and data from the storage.

Stateful pods and DNS:

Stateful pods, because they are not idenetical, get a "fully qualified name" for a DNS lookup, for example "DB-1.service_domain", "DB-2.service_domain",...

Stateless applications:

Stateless applications don't keep any records. They are deployed using the deployment component that creates replicas of pods.



Brando Sabatini and Ikbal C ©. Powered by Blogger.