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:
- StatefulSets manage the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods.
- StatefulSet is a top-level resource in the Kubernetes REST API.
- StatefulSet represents a set of pods with consistent identities.
- Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec.
- Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods.
- If you want to use storage volumes to provide persistence for your workload, you can use a StatefulSet as part of the solution.
- 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.
- StatefulSets are valuable for applications that require:
- Stable, unique network identifiers.
- Stable, persistent storage.
- Ordered, graceful deployment and scaling.
- Ordered, automated rolling updates.
- 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.
- Deployment or ReplicaSet may be better suited to your stateless needs.
- The name of a StatefulSet object must be a valid DNS subdomain name.
- 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.
- 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.
- Each Pod in a StatefulSet derives its hostname from the name of the StatefulSet and the ordinal of the Pod.
- In normal operation of a StatefulSet, there is never a need to force delete a StatefulSet Pod.
- 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.
- When a StatefulSet’s .spec.updateStrategy.type is set to RollingUpdate, the StatefulSet controller will delete and recreate each Pod in the StatefulSet.
- StatefulSets are only available in Kubernetes version 1.5 or later.
More stuff:
- StatefulSets — https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
- StatefulSet Basics — https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/
- Using StatefulSets — https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#using-statefulsets
- StatefulSet API documentation — https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/stateful-set-v1/
- Limitations of StatefulSets — https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#limitations
- StatefulSet example — https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#components
- Force deleting StatefulSet Pods — https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/
- Deploying Cassandra with a StatefulSet — https://kubernetes.io/docs/tutorials/stateful-application/cassandra/
- Running a replicated Stateful application — https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/
- Scale a StatefulSet — https://kubernetes.io/docs/tasks/run-application/scale-stateful-set/
- Delete a StatefulSet — https://kubernetes.io/docs/tasks/run-application/delete-stateful-set/
- Disruptions — https://kubernetes.io/docs/concepts/workloads/pods/disruptions/