StatefulSets on Kubernetes

StatefulSets on Kubernetes

  • Stateful apps require a stable hostname rather than a pod name with a random string.

  • Using an index, your pod name will have a persistent identification. For example, podname-0, podname-1, and podname-2 (and when the pod is rescheduled, it retains that identification).

  • The volumes associated with stateful sets will not be deleted if a statefulset is deleted or scaled down (preserving data)

  • A statefulset enables your stateful app to locate other peers by using DNS.

  • Cassandra and Elasticsearch clusters utilize DNS to discover other cluster members.

  • Using statefulsets, you can operate three Cassandra nodes on Kubernetes, numbered cassandra-0 through cassandra-2.

  • If you did not use statefulset, you would receive a dynamic hostname, which cannot be used in a configuration file since the name can change at any time.

  • statefulset also allows your stateful app to order the startup and tear down

  • When scaling up, it goes from 0 to n-1 (n=replication factor) When scaling down, it starts with the highest number (n-1) to 0