Pcornel
Containers · Kubernetes Workloads

StatefulSets

Cheat sheet · https://pcornel.dk/topic.php?topic=6145

Back to the Topic

Answer

A StatefulSet runs pods with stable names (app-0, app-1), stable network identities via a headless Service, and one PersistentVolumeClaim per pod, created and updated in order.

Remember

Pods start in order; a stuck pod blocks the next. Deleting a StatefulSet keeps PVCs. Scaling down does not delete data.

First checks

  • kubectl get sts,pods,pvc -l <selector> — first check for this topic
  • kubectl get pods -o wide — pods, status, node, IP
  • kubectl describe pod <pod> — events and conditions
  • kubectl logs <pod> [-c <c>] [--previous] — container logs (incl. previous crash)
  • kubectl get events --sort-by=.lastTimestamp — recent cluster events

Verify in this order

ordinal pods created in order → each with its PVC → stable DNS

Where it usually breaks

Scaling down does not delete PVCs, so data remains and costs storage.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6145

Confirmation

Confirm action

Continue?