Choosing the Right Kubernetes Workload for Your Application
k8s/labs/workloads/basic-statefulset.yaml — Minimal StatefulSet illustrating stable identity and ordered Pods.k8s/labs/workloads/postgres-statefulset.yaml — PostgreSQL StatefulSet with headless Service, ConfigMap, Secret, and volume claims.| Feature | Deployment | StatefulSet |
|---|---|---|
| Pod Identity | Random hash-based names (unstable) | Stable, ordered names (app-0, app-1, app-2) |
| Network Identity | No stable network identity | Stable DNS hostname per pod |
| Storage | Shared or ephemeral storage | Persistent, per-pod storage (PVCs) |
| Pod Creation Order | Random, parallel | Sequential, ordered (0 → 1 → 2) |
| Pod Termination Order | Random, parallel | Reverse order (2 → 1 → 0) |
| Scaling | Fast, parallel scaling | Graceful, one-at-a-time scaling |
| Updates | Rolling updates (replace all) | Rolling updates (ordered, one-by-one) |
| Use Case | Stateless applications | Stateful applications |