While Deployments are designed for interchangeable, stateless application replicas, stateful workloads like PostgreSQL clusters, Redis Sentinels, Kafka brokers, and Elasticsearch nodes require stable network identities, dedicated persistent volumes per replica, and strict ordered deployment & scaling. This is where StatefulSets shine.
Containers are designed to be stateless and ephemeral. To run stateful applications like PostgreSQL, MySQL, Redis, or Elasticsearch, Kubernetes provides storage abstractions that decouple persistent storage infrastructure from application workload definitions.
By default, all files created inside a container are stored on a writable container layer. When that container is deleted, the data is destroyed. Docker Volumes solve this by storing data outside the container filesystem.
Containers are ephemeral by default—when a container restarts, all data written to its local filesystem is lost. On the CKAD exam, you must demonstrate how to attach persistent storage to Pods using PVCs and StorageClasses.