StatefulSets

57

StatefulSet is the Kubernetes workload API object used to manage stateful applications. StatefulSets may be used to run distributed and clustered applications which have a need for a stable network identity and stable storage.

Stuff you wanna know:

  1. StatefulSets manage the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods.
  2. StatefulSet is a top-level resource in the Kubernetes REST API.
  3. StatefulSet represents a set of pods with consistent identities.
  4. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec.
  5. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods.
  6. If you want to use storage volumes to provide persistence for your workload, you can use a StatefulSet as part of the solution.
  7. Individual Pods in a StatefulSet are susceptible to failure, but the persistent Pod identifiers make it easier to match existing volumes to the new Pods that replace any that have failed.
  8. StatefulSets are valuable for applications that require:
    • Stable, unique network identifiers.
    • Stable, persistent storage.
    • Ordered, graceful deployment and scaling.
    • Ordered, automated rolling updates.
  9. If an application doesn’t require any stable identifiers or ordered deployment, deletion, or scaling, you should deploy your application using a workload object that provides a set of stateless replicas.
  10. Deployment or ReplicaSet may be better suited to your stateless needs.
  11. The name of a StatefulSet object must be a valid DNS subdomain name.
  12. StatefulSet Pods have a unique identity that is comprised of an ordinal, a stable network identity, and stable storage. The identity sticks to the Pod, regardless of which node it’s (re)scheduled on.
  13. For a StatefulSet with N replicas, each Pod in the StatefulSet will be assigned an integer ordinal, from 0 up through N-1, that is unique over the Set.
  14. Each Pod in a StatefulSet derives its hostname from the name of the StatefulSet and the ordinal of the Pod.
  15. In normal operation of a StatefulSet, there is never a need to force delete a StatefulSet Pod.
  16. A StatefulSet’s .spec.updateStrategy field allows you to configure and disable automated rolling updates for containers, labels, resource request/limits, and annotations for the Pods in a StatefulSet.
  17. When a StatefulSet’s .spec.updateStrategy.type is set to RollingUpdate, the StatefulSet controller will delete and recreate each Pod in the StatefulSet.
  18. StatefulSets are only available in Kubernetes version 1.5 or later.

More stuff: