---
source: https://iinventedlight.com/library/notes/kubernetes-statefulsets.md
title: "Kubernetes StatefulSets"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (kubernetes/website); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Kubernetes Authors, StatefulSets, CC BY 4.0 (kubernetes/website); Kubernetes Authors, StatefulSet Basics, CC BY 4.0 (kubernetes/website)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Kubernetes"
tags: ['kubernetes', 'statefulsets', 'storage', 'workloads']
sources:
  - id: S1
    title: "StatefulSets"
    publisher: Kubernetes Authors
    url: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
    accessed: 2026-11-04
    license: "CC BY 4.0 (kubernetes/website)"
  - id: S2
    title: "StatefulSet Basics"
    publisher: Kubernetes Authors
    url: https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/
    accessed: 2026-11-04
    license: "CC BY 4.0 (kubernetes/website)"
---
# Kubernetes StatefulSets

**Answer:** A StatefulSet manages Pods that need a stable identity: each Pod gets a fixed ordinal name (web-0, web-1, ...), a stable network identity through a headless Service, and its own persistent storage. Pods are created, scaled and deleted in order.

## Compared with a Deployment

Both run Pods from one template, but a Deployment's Pods are interchangeable.

## Key pieces

- **Headless Service:** you must create it; it gives each Pod a DNS name like `web-0.nginx`.
- **volumeClaimTemplates:** one PersistentVolumeClaim per Pod.

## Updates

```bash
kubectl patch statefulset web --type=json   -p='[{"op":"replace","path":"/spec/template/spec/containers/0/image","value":"registry.k8s.io/nginx-slim:0.24"}]'
```


## Caution

Deleting or scaling down a StatefulSet does not delete its volumes, which protects data but leaves storage to clean up.

## Claims
- id: C1
  claim: A StatefulSet maintains a sticky identity for each Pod.
  source: S1
  evidence: "A StatefulSet runs a group of Pods, and maintains a sticky identity for each of"
- id: C2
  claim: StatefulSets provide ordered, graceful deployment and scaling.
  source: S1
  evidence: "Ordered, graceful deployment and scaling."
- id: C3
  claim: StatefulSets currently require a Headless Service.
  source: S1
  evidence: "StatefulSets currently require a Headless Service"
- id: C4
  claim: The tutorial covers examining the Pod's ordinal index.
  source: S2
  evidence: "Examining the Pod's ordinal index"

## Sources
- [S1] StatefulSets. Kubernetes Authors. https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ . License: CC BY 4.0 (kubernetes/website). Accessed 2026-11-04.
- [S2] StatefulSet Basics. Kubernetes Authors. https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/ . License: CC BY 4.0 (kubernetes/website). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
