In a stateful application, every instance is unique and knows its own identity, and the main ingredients of that identity are the long-lived storage and the networking coordinates.
StatefulSet is designed for managing non-fungible Pods, as opposed to ReplicaSet, which is for managing identical replaceable Pods.
Networking:
Each Pod will get a DNS entry where clients can directly reach out to it in a predictable way.
For example, if app has a name app
, we can reach our app-0
Pod through its fully qualified domain name:
app-0.service-name.default.svc.cluster.local
, where the Pod’s name is prepended to the Service name.