StatefulSets
StatefulSets are a stable resource in the apps/v1
API group. Their use case is stateful components of your application, such as Pods that are not intended to be ephemeral and need more order than is provided by something such as a Deployment.
Stateful components of a microservices application are usually the hardest to implement, and platforms such as Kubernetes have been somewhat slow to implement features to handle them. StatefulSets are a step toward improving this.
In many ways, StatefulSets are like Deployments. For example, we define them in a YAML file that we POST
to the API server as a desired state. A controller implements the work on the cluster and a background watch loop makes sure that the current state matches the desired state. However, there are several significant differences. These include:
- StatefulSets give Pods deterministic and meaningful names. Deployments do not.
- StatefulSets always start and delete Pods in a specific order. Deployments...