✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Kubernetes StatefulSet Disruption Management

Kubernetes StatefulSet Disruption Management controls stateful app updates by managing pod disruptions and ensuring data integrity during scale operations.

Kubernetes StatefulSet Disruption Management is the operational procedure for responding to both voluntary disruptions (planned node drains, cluster upgrades) and involuntary disruptions (node failure) affecting StatefulSet Pods, covering how the eviction API interacts with PodDisruptionBudget-protected ordinals and the distinct manual recovery path required when a node becomes unreachable rather than cleanly drained.


Voluntary Disruption Through the Eviction API

How kubectl drain Interacts With StatefulSet Pods

A node drain issues eviction requests against every Pod on that node, including StatefulSet Pods, and the API server rejects any eviction that would violate an applicable PodDisruptionBudget, causing the drain command to pause and retry rather than forcibly removing a protected ordinal.

kubectl drain node-3 --ignore-daemonsets
error when evicting pod "disruption-management-example-2": Cannot evict pod as it would violate the pod's disruption budget.

Successful Eviction Still Triggers Full Recreation Sequence

Once eviction succeeds, the affected ordinal's Pod is deleted and recreated according to the normal StatefulSet mechanics, volume detachment and reattachment, image pull, ordered readiness, following the same sequence and timing considerations described in persistent storage behavior, meaning a voluntary disruption is not instantaneous even once permitted.


Involuntary Disruption From Node Failure

The Kubelet Cannot Confirm Termination

When a node fails outright rather than being cleanly drained, the API server has no confirmation that the Pod on it has actually stopped, since the kubelet that would normally report this is itself unreachable. The StatefulSet controller's at-most-one guarantee prevents it from creating a replacement until this uncertainty is resolved.

kubectl get pod disruption-management-example-2 -o jsonpath='{.status.phase}'
Running

Despite the underlying node being down, the API may still show the Pod as Running because no updated status has been reported.


The Manual Recovery Decision

Verifying True Node Failure Before Intervening

Disruption management practice requires independently confirming, through infrastructure-level monitoring or the cloud provider's own node status, that the node is genuinely down and not merely experiencing a transient network partition, before taking any manual action, since a network partition can resolve on its own and a premature intervention risks the exact dual-instance scenario the at-most-one guarantee exists to prevent.

kubectl get node node-3 -o jsonpath='{.status.conditions[?(@.type=="Ready")]}'

Force-Deleting to Unblock Replacement

Only after independent confirmation of genuine node failure does disruption management practice proceed with force-deleting the affected Pod, explicitly bypassing the normal graceful termination wait, to allow the StatefulSet controller to create its replacement.

kubectl delete pod disruption-management-example-2 --grace-period=0 --force

Post-Recovery Verification

Confirming Single-Instance Correctness

After forced recovery, disruption management practice includes verifying, at the application level where possible, that only one instance is actually claiming that ordinal's identity, checking cluster membership from the application's own perspective as an additional safeguard beyond Kubernetes' own object state.

kubectl exec disruption-management-example-0 -- cluster-status | grep node-2

Disruption Management Diagram

Voluntary (drain) → PDB-gated eviction API Involuntary (node failure) → manual verify + force delete

Recognizing that these two disruption categories require entirely different response procedures, one automated and PDB-governed, the other requiring deliberate manual judgment, is central to handling StatefulSet disruptions without either unnecessary downtime or a correctness-compromising premature recovery action.