A Kubernetes StatefulSet runs a group of Pods where each Pod keeps its own name and its own volume. It is what you use for databases, queues and anything else where Pod number 2 cannot stand in for Pod number 0. 5 things to know before you run one:
Bottom line
- StatefulSet = Pods with a fixed name and their own volume. web-0 stays web-0 after every restart, and it gets the same disk back
- The order is fixed. Pods are created from 0 up, removed from the top down, and updated from the top down, 1 at a time
- The volumes outlive the Pods. Scale down or delete the StatefulSet and the PersistentVolumeClaims stay, and so does the bill, until you delete them or set a retention policy
- A StatefulSet does NOT replicate your data. It gives each Pod an identity and a disk. Replication, failover and backups are the job of the app or of an Operator
- If the Pods are interchangeable, use a Deployment. A StatefulSet is slower to roll and harder to repair, so use it only when you need what it gives
A small StatefulSet to start from, on Kubernetes v1.37:
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
clusterIP: None
selector:
app: nginx
ports:
- port: 80
name: web
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: nginx
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.29
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1GiThe 5 commands you will use most:
kubectl apply -f web.yaml
kubectl get sts web
kubectl get pods -l app=nginx
kubectl get pvc
kubectl rollout status sts/webA database on Kubernetes that nobody wants to touch on release day? Get a free DevOps assessment: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.
Find your situation:
- You are choosing between the 2: StatefulSet vs Deployment
- You are writing a manifest: a StatefulSet YAML for production
- You scaled down and the disks are still there: the volumes outlive the Pods
- A rollout is stuck on 1 Pod: a stuck rollout needs 2 fixes
- A node died and the Pod did not come back: when a node dies
- Something is broken right now: 7 symptoms and the first command
A StatefulSet gives each Pod a name it keeps
A Deployment treats its Pods as copies. A StatefulSet treats them as individuals.
Every Pod in a StatefulSet gets an identity made of 3 things:
- An ordinal: a number from 0 to replicas minus 1
- A stable name: the StatefulSet name plus the ordinal, so
web-0,web-1,web-2 - Stable storage: its own PersistentVolumeClaim, created from a template
Identity = ordinal + name + volume. It sticks to the Pod, whichever node the Pod lands on.
Delete web-1 and the new Pod is web-1 again, with the same volume.

The name is also a DNS name. This is what the headless Service is for.
A headless Service is a Service with clusterIP: None. It has no virtual IP and does no load balancing. It only publishes DNS records for the Pods behind it.
With a headless Service called nginx in the default namespace, each Pod gets its own address:
web-0.nginx.default.svc.cluster.local
web-1.nginx.default.svc.cluster.local
web-2.nginx.default.svc.cluster.localThe pattern is $(pod name).$(service name).$(namespace).svc.cluster.local.
So a replica can always reach web-0 at web-0.nginx, and a client can pick the exact Pod it wants to write to.
4 details that save time later:
- You create the headless Service yourself. The StatefulSet points at it with
serviceName - The Pod IP can change after a restart. The name does not. Connect by name
- Clients that are happy with any healthy Pod can use a second, normal ClusterIP Service over the same Pods
- A new Pod's DNS name may not resolve right away. A lookup made before the Pod exists gets cached as a miss (CoreDNS caches for 30 seconds)
Each Pod also gets 2 labels you can select on:
| Label | Value | Use it for |
|---|---|---|
statefulset.kubernetes.io/pod-name | web-0 | A Service that targets 1 Pod |
apps.kubernetes.io/pod-index | 0 | Routing or filtering logs and metrics by ordinal (stable since v1.32) |
The numbering starts at 0. You can change that with spec.ordinals.start (stable since v1.31), which helps when you move replicas from one StatefulSet to another.
StatefulSet vs Deployment
The 2 use the same Pod template. The difference is what happens around the Pods.
| Deployment | StatefulSet | |
|---|---|---|
| Pod names | Random suffix, new on every replacement | Fixed: web-0, web-1, web-2 |
| Pods are | Interchangeable | Individuals |
| Storage | All replicas share the same claim | 1 claim per Pod, from a template |
| DNS | 1 name for the Service | 1 name per Pod, through a headless Service |
| Create and scale | Any order, in parallel | 0 first, 1 at a time (by default) |
| Rolling update | New Pods alongside old ones: 25% surge and 25% unavailable by default | Highest ordinal first, the old Pod stops before the new one starts |
| In between | A ReplicaSet per revision | Nothing. The StatefulSet manages the Pods directly |
| Rollback | kubectl rollout undo | kubectl rollout undo, plus manual work if a Pod is stuck |
| Good for | APIs, web apps, workers | Databases, queues, search clusters, anything with a quorum |
The Kubernetes docs list 4 reasons to pick a StatefulSet:
- Stable, unique network identifiers
- Stable, persistent storage
- Ordered, graceful deployment and scaling
- Ordered, automated rolling updates
My rule: if you need 0 of the 4, use a Deployment.
(A StatefulSet for a stateless API is a Deployment with extra waiting.)
The same docs say it directly: if an app does not need stable identifiers or ordered deployment, deletion or scaling, deploy it with a Deployment or a ReplicaSet.
1 database Pod with 1 disk can be a Deployment
A single-instance database does not need ordinals.
A Deployment with 1 replica and 1 PersistentVolumeClaim works, with 2 conditions:
- Do not scale it. Every replica of a Deployment mounts the same claim
- Set
strategy.type: Recreate. With 1 replica, the default rolling update starts the new Pod before it stops the old one. With a ReadWriteOnce volume the new Pod can wait for the disk forever while the old Pod waits for the new one
I still use a StatefulSet with 1 replica for this. The old Pod always stops before the new one starts, and adding a replica later does not mean a migration.
And a DaemonSet is a different thing: 1 Pod per node, for node-level agents such as log collectors.
A StatefulSet YAML for production
The small manifest at the top is enough for a first try. This one adds what I set before real data goes in.
If you applied the first one, delete that StatefulSet and its claims before you apply this one: the volume template cannot be changed in place.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: nginx
replicas: 3
minReadySeconds: 10
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
persistentVolumeClaimRetentionPolicy:
whenDeleted: Retain
whenScaled: Retain
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
terminationGracePeriodSeconds: 30
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: nginx
topologyKey: kubernetes.io/hostname
containers:
- name: nginx
image: nginx:1.29
ports:
- containerPort: 80
name: web
readinessProbe:
tcpSocket:
port: 80
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 128Mi
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: ["ReadWriteOncePod"]
storageClassName: my-storage-class
resources:
requests:
storage: 10GiReplace my-storage-class with a class from kubectl get storageclass. With a name that does not exist, the claims and the Pods stay Pending.
The probe here only checks that nginx listens on port 80. For a real database, use a probe that checks that the member has joined and caught up.
What each part does:
| Field | Default | What it does |
|---|---|---|
serviceName | none | The headless Service that gives the Pods their DNS names |
replicas | 1 | How many Pods. Leave it out when a HorizontalPodAutoscaler owns the number |
selector | required | Must match the labels in the Pod template, or the API rejects the object |
minReadySeconds | 0 | How long a Pod must stay Ready before it counts as available and the rollout moves on |
podManagementPolicy | OrderedReady | OrderedReady or Parallel |
updateStrategy.type | RollingUpdate | RollingUpdate, OnDelete, or Recreate (alpha in v1.37) |
rollingUpdate.partition | 0 | Only Pods with this ordinal or higher get updated |
rollingUpdate.maxUnavailable | 1 | How many Pods may be down during an update |
revisionHistoryLimit | 10 | How many old revisions to keep for rollback |
persistentVolumeClaimRetentionPolicy | Retain, Retain | What happens to the claims on delete and on scale down |
volumeClaimTemplates | none | The template for each Pod's claim |
3 choices in this manifest are worth explaining:
- ReadWriteOncePod: ReadWriteOnce allows 1 node, and several Pods on that node can still mount the volume. ReadWriteOncePod allows 1 Pod in the whole cluster. The Kubernetes project recommends it for production. It needs a CSI driver
- Pod anti-affinity on the hostname: by default 2 replicas can land on the same node, and then 1 node failure takes both. With the required rule and too few nodes, the extra Pods stay Pending
- A termination grace period above 0: the docs call a value of 0 "unsafe and strongly discouraged" for StatefulSet Pods. Give the app time to flush and close
The Pod template has 1 hard rule: restartPolicy must be Always.
The volumes outlive the Pods
volumeClaimTemplates is the part a Deployment does not have.
For every Pod, the StatefulSet creates 1 PersistentVolumeClaim per template. The names follow the template name, the StatefulSet name and the ordinal:
www-web-0
www-web-1
www-web-2What happens to a claim:
- The Pod restarts or moves to another node: same claim, same data
- You delete the Pod: the new Pod with the same name gets the same claim
- You scale down: the Pod goes, the claim stays
- You delete the StatefulSet: the Pods go, the claims stay
Scale from 3 to 1 and you still have 3 claims and 3 volumes.

This is on purpose. The docs put it under "Limitations" and give the reason: data safety is worth more than an automatic purge.
It has 2 consequences:
- You pay for disks that no Pod uses. List them with
kubectl get pvcafter every scale down - Old data comes back. Scale up again and web-1 gets www-web-1, with whatever was on it. A replica that rejoins with stale data is a surprise for some databases
Let Kubernetes delete the claims for you
persistentVolumeClaimRetentionPolicy is stable since v1.32. It has 2 settings:
| Setting | When it applies | Retain (default) | Delete |
|---|---|---|---|
whenDeleted | The StatefulSet is deleted | Claims stay | All claims from the template are deleted |
whenScaled | Replicas go down | Claims stay | Only the claims of the removed Pods are deleted |
The policy never fires when a Pod is replaced after a node failure. The new Pod keeps the claim.
When / Use:
- A database you care about: Retain and Retain. Clean up by hand
- A cache or a test environment: Delete and Delete
- A cluster that rebuilds replicas from peers:
whenDeleted: Retain,whenScaled: Delete
1 more layer sits below this. When a claim is deleted, the reclaim policy of its volume decides what happens to the disk. The volume gets that policy from the StorageClass when it is created. Dynamically provisioned volumes default to Delete, which removes the cloud disk too.
Deleted claim + reclaim policy Delete = the data is gone.
You cannot edit volumeClaimTemplates
4 fields of a StatefulSet are immutable in v1.37: selector, volumeClaimTemplates, serviceName and podManagementPolicy.
So you cannot grow the disks by changing the template.
To resize, edit each PersistentVolumeClaim to a larger size. This works when the StorageClass has allowVolumeExpansion: true and the driver supports it. A claim in use is resized without recreating the Pod.
The template keeps the old size, so Pods you add later start with the old size. We wrote the full procedure in how to resize Kubernetes persistent volumes without downtime.
(A proposal to make the template editable exists as KEP-4650. As of v1.37 it has not shipped.)
The order: up from 0, down from the top
With the default policy, OrderedReady, a StatefulSet does 1 thing at a time:
- Create and scale up: web-0, then web-1, then web-2
- Scale down: web-2, then web-1, then web-0
- Rolling update: web-2, then web-1, then web-0
Each Pod must be Running and Ready before the next one starts.

Before a Pod is removed, every Pod above it must be fully shut down.
This is useful for a database: the primary starts first, and a replica starts only when it has something to copy from.
It also means 1 broken Pod blocks everything behind it:
- web-0 fails while web-1 is up: web-2 is not created until web-0 is Running and Ready again
- Any Pod is unhealthy: you cannot scale down
Why block the scale down? Kubernetes cannot tell a permanent fault from a short one, and removing healthy members on top of a sick one can drop a cluster below its minimum.
Parallel: identity without the waiting
Some systems need the names and the disks, and do not care about the order.
For those, set podManagementPolicy: Parallel. The StatefulSet then starts and stops all Pods at once and does not wait for 1 to be Ready before the next.
2 things to know:
- The field is immutable. Choose before you create the StatefulSet
- In v1.37 it also changes rolling updates: with
maxUnavailableabove 1, up to that many Pods are replaced at the same time
Rolling updates go from the last Pod to the first
Change the Pod template and the StatefulSet starts a rolling update.
It deletes the Pod with the highest ordinal, creates it again from the new template, waits until it is Running and Ready (plus minReadySeconds), then moves to the next one down.
A Deployment adds new Pods first. A StatefulSet cannot: only 1 web-2 may exist at a time. So every update takes each Pod down for a moment.
kubectl set image sts/web nginx=nginx:1.29.1
kubectl rollout status sts/web
kubectl rollout history sts/web
kubectl rollout undo sts/webThe 3 strategies:
| Strategy | What it does | Use it when |
|---|---|---|
| RollingUpdate (default) | Replaces Pods from the highest ordinal down | Almost always |
| OnDelete | Does nothing until you delete a Pod yourself | You or an Operator must control the exact order |
| Recreate (alpha in v1.37, off by default) | Deletes all Pods, then creates the new ones | Versions cannot run side by side and downtime is fine |
maxUnavailable lets an update take more than 1 Pod at a time. It is beta and on by default in v1.37, and its default value is 1.
It had a bumpy road: on in v1.35.0, switched off from v1.35.4 through v1.36 because of a regression, and on again in v1.37. The API reference also says it "might not be effective" with OrderedReady, so it mostly matters with Parallel.
A canary with partition
partition splits the Pods in 2 groups.
Pods with an ordinal at or above the partition get the new template. Pods below it stay on the old one, even if they are deleted and recreated.
With 4 replicas, partition: 2 updates only web-2 and web-3.

A canary on a 3 replica StatefulSet, step by step:
# 1. Park the rollout: a partition above the last ordinal
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":3}}}}'
# 2. Change the template. Nothing rolls yet
kubectl set image sts/web nginx=nginx:1.29.1
# 3. Canary: only web-2 gets the new version
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":2}}}}'
# 4. Happy with it? Finish the rollout
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":0}}}}'Lower the partition 1 step at a time for a phased rollout.
For a database, think about which Pod is the canary. In setups that keep the primary at ordinal 0, the highest ordinal is a replica, which is what you want to test first. If your database can fail over, check who is primary before you start.
A stuck rollout needs 2 fixes
This is the trap that most StatefulSet guides skip.
You push a template with a bad image or a config that never becomes Ready. The rollout replaces web-2, web-2 never gets Ready, and the StatefulSet stops and waits.
So you revert the template. And nothing happens.
Why? Because of a known issue: the StatefulSet keeps waiting for the broken Pod to become Ready before it applies the good template to it. (It never becomes Ready.) The docs describe this for the default OrderedReady policy.
The fix has 2 steps:
- Revert the template:
kubectl rollout undo sts/web - Delete the Pods that started with the bad template:
kubectl delete pod web-2
The StatefulSet then recreates them from the good template.
Stuck rollout fix = revert + delete the broken Pod.
How rollback works
Every template change is saved as a ControllerRevision object. The StatefulSet keeps 10 by default (revisionHistoryLimit).
kubectl rollout history statefulset/web
kubectl rollout undo statefulset/web --to-revision=3A rollback applies the old Pod template as a new revision.
It rolls back the template only. The data on the volumes stays as the new version left it, so a rollback after a schema migration is a database problem, and Kubernetes will not solve it for you.
Scale and delete without losing data
Scaling is 1 command:
kubectl scale sts web --replicas=53 things to know:
- If
replicasis in your manifest, the nextkubectl applysets it back. Change the number in Git - A HorizontalPodAutoscaler can scale a StatefulSet. Remove
spec.replicasfrom the manifest when it does - Scaling adds a Pod. It does not tell your database that a new member exists. That part is on the app
Deleting has more ways to go wrong.
# Delete the StatefulSet and its Pods
kubectl delete statefulset web
# Delete only the StatefulSet object and keep the Pods running
kubectl delete statefulset web --cascade=orphan
# The claims, when you are sure
kubectl delete pvc -l app=nginxWhat to expect:
- The headless Service is not deleted. Remove it separately
- The claims are not deleted, unless
whenDeletedis Delete - The docs give no guarantee on how the Pods are terminated when the StatefulSet is deleted. For an ordered shutdown, scale to 0 first and delete after (with
whenScaled: Deletethis removes the claims as well) - With
--cascade=orphanthe Pods keep running, and a StatefulSet you create again with the same selector adopts them
Always:
- Take the backup, and test that it restores
- Check
whenScaled: if it is Delete, scaling to 0 deletes every claim - Scale to 0
- Delete the StatefulSet
- Delete the claims last
When a node dies, the Pod is not replaced
This surprises teams that are used to Deployments.
A Deployment replaces the Pods of a dead node after a few minutes. A StatefulSet does not.
The reason is the rule that the whole thing is built on: at most 1 Pod per identity at any time.
When a node stops answering, Kubernetes cannot know if the Pod is dead or just cut off from the network. If it started a second web-0 and the first one was still writing, 2 Pods would write to the same data. That is split brain.
So the Pod on the unreachable node shows Terminating or Unknown, and it stays that way until 1 of 3 things happens:
- The Node object is deleted (by you or by the cloud's node controller)
- The kubelet on the node comes back and stops the Pod
- Someone force deletes the Pod
On a managed cloud, number 1 usually happens for you when the instance is terminated.
On bare metal, or when the instance is stuck, you do it. If the node is powered off for sure, mark it out of service:
kubectl taint nodes NODE_NAME node.kubernetes.io/out-of-service=nodeshutdown:NoExecuteThis force deletes the Pods on that node and detaches their volumes at once, so the StatefulSet can create them elsewhere. The feature is stable since v1.28. Remove the taint yourself when the node is back.
The last resort is the force delete:
kubectl delete pods web-0 --grace-period=0 --forceWith this command you promise Kubernetes that the old Pod will never talk to its peers again. If you are wrong, you get a duplicate identity and possibly data loss. The docs say that normal operation never needs it.
1 more thing ties a Pod to a place: the disk. EBS volumes, GKE zonal disks and locally redundant Azure disks live in 1 zone. A Pod with such a volume can only run in that zone. If the zone has no room, the Pod stays Pending.
A StatefulSet does NOT run your database
StatefulSet = identity + disk + order.
It does not:
- Copy data between Pods
- Pick a new primary when the old one dies
- Add or remove members from the cluster config
- Back anything up
The official tutorials show how much is left to you. The MySQL example uses an init container to turn the ordinal into a server ID, treats ordinal 0 as the primary, and clones each new replica from the Pod before it with Percona XtraBackup. The docs add that it is not a production configuration.
The same goes for Cassandra (seed nodes found by the DNS name of cassandra-0) and ZooKeeper (the member list is written into the config).
This gap is what Operators fill. An Operator is a controller that knows 1 application: it can run backups and restores, do upgrades and, for some applications, pick a new leader.
Some Operators manage a StatefulSet for you. And some left StatefulSets behind:
- CloudNativePG (PostgreSQL) manages Pods and claims directly, with no StatefulSet. Its reasons include that 1 template serves all Pods and that resizing claims is a known StatefulSet limitation
- Strimzi (Kafka) replaced StatefulSets with its own StrimziPodSet and removed StatefulSet support in 0.35.0. 1 of its reasons: in a StatefulSet only the Pod with the highest ordinal can be removed
How I decide:
- The cloud has it as a managed service and you have no reason to say no: use the managed service
- A mature Operator exists: use the Operator and let it decide what is underneath
- Neither: a StatefulSet, and you own replication, failover and backups
Keep the quorum during node maintenance
A 3 member ZooKeeper needs 2 healthy members to accept writes. Most clustered databases have a rule like it.
The rolling update respects this on its own: 1 Pod at a time.
A node drain does not. Draining 2 nodes at once can evict 2 members. A PodDisruptionBudget stops that:
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web
spec:
maxUnavailable: 1
selector:
matchLabels:
app: nginxFor quorum apps the docs suggest maxUnavailable: 1, or minAvailable set to the quorum size. I use maxUnavailable, because it stays correct when the replica count changes.
A PodDisruptionBudget guards evictions such as drains. It does not limit the StatefulSet's own rolling update.
Always, for anything with a quorum:
- A PodDisruptionBudget with
maxUnavailable: 1 - Anti-affinity or topology spread, so 2 members do not share a node or a zone
- A readiness probe that passes only when the member has joined and caught up
Storage classes on EKS, GKE and AKS
A volumeClaimTemplate with no storageClassName uses the cluster's default StorageClass. A cluster can have none, and then the claims stay Pending.
| Cloud | What you get | Watch for |
|---|---|---|
| EKS | The EBS CSI driver is an add-on you install. On EKS Auto Mode the storage capability is built in | Auto Mode does not create a StorageClass. You create one (AWS's example uses gp3 and WaitForFirstConsumer) |
| GKE | GKE's docs give standard-rwo as the default for ReadWriteOnce claims. It uses WaitForFirstConsumer | Check with kubectl get storageclass on a Standard cluster. Zonal disks: the Pod is scheduled to the disk's zone |
| AKS | The default class matches managed-csi: Standard SSD, expandable, reclaim policy Delete | A locally redundant disk cannot attach to a node in another zone. From Kubernetes 1.29 the built-in classes use zone-redundant disks in multi-zone clusters |
Check 3 settings on the class before the first Pod starts:
volumeBindingMode: WaitForFirstConsumer: the disk is created after the Pod is scheduled, in the zone where the Pod will run. With Immediate, the disk can land in a zone where the Pod cannotallowVolumeExpansion: true: or you cannot grow the disks laterreclaimPolicy: Delete is the default. For data you cannot lose, Retain keeps the disk after the claim is gone
What changed for StatefulSets from v1.34 to v1.37
| Version | Change | State |
|---|---|---|
| v1.37 | Recreate update strategy | Alpha, off by default |
| v1.37 | maxUnavailable for rolling updates | Beta, on by default again |
| v1.37 | kubectl describe statefulset shows the Service name, the pod management policy and the claim retention policy | Shipped |
| v1.36 | Available replicas are counted without delay, so rollouts move faster | Shipped |
| v1.35.4 and v1.36 | maxUnavailable switched off after a regression with Parallel | Beta, off |
| v1.35 | maxUnavailable moved to beta | Beta, on in 1.35.0 to 1.35.3 |
| v1.35 | Fix for a rollout that started by itself during a control plane upgrade from v1.33 to v1.34 | Shipped |
| v1.34 | minReadySeconds fix and Pod spec validation on create | Shipped |
Older, and still missing from most guides: claim retention policy (stable in v1.32), the pod index label (stable in v1.32), start ordinal (stable in v1.31), ReadWriteOncePod (stable in v1.29) and the out-of-service taint (stable in v1.28).
Debug a StatefulSet: 7 symptoms and the first command
| Symptom | Likely cause | First command |
|---|---|---|
| web-0 is Pending | The claim is not bound: no default StorageClass, or no matching volume | kubectl describe pvc www-web-0 |
| web-0 is Pending and the claim is Bound | The volume is in a zone with no room, or anti-affinity has no node left | kubectl describe pod web-0 |
| web-1 is never created | web-0 is not Running and Ready | kubectl describe pod web-0 |
| The rollout hangs on 1 Pod | The new template never gets Ready | kubectl rollout status sts/web, then revert and delete the Pod |
| The scale down does nothing | A Pod in the set is unhealthy | kubectl get pods -l app=nginx |
| A Pod is Terminating or Unknown for a long time | Its node is unreachable | kubectl get nodes |
| A Pod name does not resolve | No headless Service, a wrong serviceName, or the Pod is not Ready yet | kubectl get svc nginx |
For the Pod-level statuses (CrashLoopBackOff, ImagePullBackOff, OOMKilled), use the table in our Kubernetes Pod guide.
Checklist before a StatefulSet takes real data
- A headless Service exists and
serviceNamepoints at it - The StorageClass is named in the template, with WaitForFirstConsumer and volume expansion on
- The access mode is ReadWriteOncePod where the driver supports it
persistentVolumeClaimRetentionPolicyis a decision, written down- A readiness probe that reflects the real state of the member
terminationGracePeriodSecondsis long enough for a clean shutdown, and never 0- Requests and a memory limit are set
- Anti-affinity or topology spread across nodes and zones
- A PodDisruptionBudget with
maxUnavailable: 1 - Backups run, and a restore was tested
- The team knows the 2 step fix for a stuck rollout
- The team knows what to do when a node dies, and that force delete is the last resort
- Somebody owns replication and failover: the app, an Operator, or a managed service
FAQ
What is a StatefulSet in Kubernetes?
A StatefulSet is the workload object for stateful apps. It runs a group of Pods where each Pod has a fixed name, a stable DNS name and its own PersistentVolumeClaim, and it creates, scales and updates them in a fixed order.
What is the difference between a StatefulSet and a Deployment?
A Deployment runs interchangeable Pods with random names that share any storage. A StatefulSet runs Pods that each keep a name and a volume across restarts, and it changes them 1 at a time in order.
When should I use a StatefulSet?
Use it when each replica needs its own disk or its own stable network name: databases, message queues, search clusters, anything with a quorum. If any replica can replace any other, use a Deployment.
Does a StatefulSet need a headless Service?
For stable DNS names, yes. The headless Service gives every Pod its DNS name, and you create it yourself. The StatefulSet refers to it with serviceName.
What happens to the volumes when I delete a StatefulSet?
They stay. By default the PersistentVolumeClaims and their data survive both a delete and a scale down. Set persistentVolumeClaimRetentionPolicy to Delete if you want Kubernetes to remove them.
Can I change volumeClaimTemplates after creating the StatefulSet?
No. The field is immutable. To grow the disks, edit each PersistentVolumeClaim, which works when the StorageClass allows volume expansion.
How do I restart a StatefulSet?
Run kubectl rollout restart statefulset/web. With the default RollingUpdate strategy the Pods are replaced 1 at a time from the highest ordinal down, and each one gets its volume back.
Does a StatefulSet replicate data between Pods?
No. It gives each Pod an identity and a disk. Replicating data between them is the job of the application or of an Operator.
A recap
If you take away 1 thing, let it be this: a StatefulSet keeps names and disks stable, and nothing more.
Everything in this guide follows from that:
- Fixed names, so members find each other
- 1 volume per Pod, so data survives a restart
- A fixed order, so a cluster forms and updates safely
- At most 1 Pod per name, so 2 Pods never write to the same data
- Volumes that stay behind, so a mistake does not delete a database
You can set all of this up yourself with the YAML and the checklist above.
If you would like a second pair of eyes on your stateful workloads, get a free DevOps assessment. Next reads: Kubernetes Deployment, Kubernetes Pod and Kubernetes Service.




