Controllers and Pod Recreation
Deployment Pods are interchangeable and named at random; StatefulSet Pods have stable identities and each keeps its own disk across deletion and rescheduling. That single difference is why databases use one and web front ends use the other. Both run in one namespace here, get the same Pod deleted, and are compared on the same screen.
Kubernetes Fundamentals Guide 10 of 46 Beginner
- Kubernetes1.36.4
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- Cluster4 nodes
- TimeAbout 14 min
- Reviewed23 August 2026
Written against the versions above. `volumeClaimTemplates` creates one PVC per replica, named `<template>-<statefulset>-<ordinal>`. Those PVCs are deliberately NOT deleted with the StatefulSet. `persistentVolumeClaimRetentionPolicy` can change that, and is left at its default here so the default behaviour is what you see.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
Before you start
- A cluster with a default StorageClass. This one uses
local-path, which provisions on first use. - The session creates namespace
kx-sts, a headless Servicedb, a StatefulSetdbwith two replicas and a 64Mi claim each, and a Deploymentwebwith two replicas for comparison.
-
Named in order, with a disk each
-
Write something only db-0 has
-
Delete it, and the same Pod comes back
-
The same test on a Deployment
-
What deleting the StatefulSet leaves behind