CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Administrator

StatefulSets: Stable Identity and Ordered Startup

A Deployment's Pods are interchangeable and get random names. A StatefulSet's are numbered, start in order, keep their own volume, and get their own DNS name. Build one with a headless Service and per-Pod storage, delete a Pod to watch it come back as itself, then see the PVCs survive the StatefulSet's deletion.

Workloads Guide 28 of 103 Intermediate

Written against the versions above. PV names, UIDs and addresses are generated per run. The StorageClass here is local-path; any dynamic provisioner behaves the same for this exercise.

Four nodes with a default StorageClass, so volumeClaimTemplates can provision per-Pod storage.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

Before you start

  1. Two objects, because identity needs a name to resolve

  2. Numbered names and staggered ages

  3. One volume per Pod, provisioned automatically

  4. Per-Pod DNS from the headless Service

  5. Delete a Pod and watch it come back as itself

  6. The PVCs outlive the StatefulSet

  7. Clean up, storage included

Official sources