Skip to main content
Version: 1.0.0

StatefulSet

StatefulSet is a Kubernetes resource used to manage stateful applications like databases or distributed systems. Unlike a Deployment, a StatefulSet maintains sticky identities for each of its pods.

When a StatefulSet scales up or down, pods are created or deleted in an orderly fashion, with respect to their ordinal index. Each pod gets its own persistent storage volume that it retains even if the pod needs to be rescheduled. The network identity of each pod also remains the same. This provides consistency for stateful workloads that rely on stable network IDs and persistent storage. For example, you could run a database like MySQL as a StatefulSet. As you scale up replicas, each pod gets created with its own storage volume that persists even if the pod moves hosts. The StatefulSet also gives each pod a unique stable name like "mysql-0", "mysql-1" etc. which allows the pods to always find and communicate with each other.