What is StatefulSet
Used for stateful application such as databases and replaces Deployment which are typically used for stateless applications.
- maintains a sticky identity for each pod, this is the stateful application name plus number, i.e. mysql-0, mysql-1, etc
- creation of stateful applications are in order, mysql-0 is created first and the rest follow sequentially only if the previous one has succeeded
- deletion of stateful applications is in reverse but still ordered. mysql-2 is deleted then -1 then -0 only if the previous step succeeds
- the above are built-in K8s policies to protect data
- each pod in statefulset will get its own dns/service
Stateful Apps in K8s
- it's very complex
- K8s provide the capability but not the full solution
- a lot needs to be done by operator/admin
- cloning and data synchronization
- remote storage
- backups
stateful apps are not perfect for containerized environments