StatefulSet
What is StatefulSet?
StatefulSet: Like a Deployment but for stateful apps that need stable network identities and stable per-Pod storage — databases, queues, clustered services. A StatefulSet runs applications that need a stable identity and their own storage in Kubernetes, such as databases, message brokers and clustered services. Unlike a Deployment, each pod gets a fixed name, like db-0 and db-1, a stable network address and its own persistent volume that follows it when the pod is recreated. Pods are started and stopped in order.
Frequently asked questions about StatefulSet
What should you keep in mind with StatefulSet?
Running databases in Kubernetes is possible but takes care: backups, upgrades, failover and storage performance all become your responsibility. For many teams, a managed database from the cloud provider is simpler and safer, with the application in Kubernetes connecting to it. If you do run stateful services yourself, operators such as CloudNativePG for PostgreSQL automate much of the hard work.
What does an example of StatefulSet look like?
apiVersion: apps/v1 kind: StatefulSet metadata: name: db spec: serviceName: db replicas: 3 selector: matchLabels: { app: db } template: metadata: labels: { app: db } spec: containers: - name: db image: postgres:16 At a glance
| Category | Kubernetes |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |