Pcornel
Technology Comparisons

Deployment vs StatefulSet

Compare the Kubernetes controllers for stateless and stateful workloads.

DimensionDeploymentStatefulSetWhat it means in practice
Pod identityRandom Pod names; Pods are interchangeable.Stable names <name>-0, <name>-1.Use StatefulSets when members must know each other by name.
StorageShared or no PVCs; all replicas use the same claim if any.One PVC per Pod from volumeClaimTemplates.StatefulSet PVCs are kept when Pods or the set are deleted.
OrderingPods start and stop in parallel.Ordered start, stop and update (by default).Ordered rollouts are slower but safer for clustered databases.
Network identityReached through a normal Service.Headless Service gives per-Pod DNS names.Per-Pod DNS is <pod>.<service>.<ns>.svc.cluster.local.
ScalingFast; any Pod can be removed.Removes the highest ordinal first.Scaling down does not delete data.
Verificationkubectl rollout status deployment/<name>kubectl rollout status statefulset/<name>; kubectl get pvcCheck each StatefulSet Pod has its own Bound PVC.

← All comparisons

Confirmation

Confirm action

Continue?