Kubernetes StatefulSet¶
A StatefulSet is a Kubernetes API object used to manage stateful applications. Unlike a Deployment, which manages stateless applications, a StatefulSet provides guarantees about the ordering and uniqueness of pods^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Key Characteristics¶
StatefulSets are distinct because they maintain a sticky identity for each of their Pods. These pods are created from the same spec, but they are not interchangeable; each has a persistent identifier that it maintains across any rescheduling^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
This management style is essential for applications that require: * Stable, unique network identifiers: Each Pod gets a predictable DNS name. * Stable, persistent storage: Pods can be rescheduled while retaining their specific data volumes. * Ordered, graceful deployment and scaling: Pods are created or terminated sequentially, rather than all at once.
Configuration¶
In typical Helm chart configurations, such as those for complex applications like Jenkins, the StatefulSet behavior can be customized^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Key configuration parameters include:
- Update Strategy: Defines how updates are rolled out to the pods (e.g.,
RollingUpdate). - Pod Management Policy: Controls how pods are created and deleted (e.g.,
OrderedReadyvsParallel). - Persistence: StatefulSets are often paired with PersistentVolumeClaims (PVCs) to ensure data persists beyond the lifecycle of individual pods^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Use Cases¶
StatefulSets are the standard workload controller for distributed systems that rely on stable identities or clustered data. Common use cases include:
- Databases (e.g., MySQL, PostgreSQL, Cassandra)
- Message queues (e.g., Kafka, RabbitMQ)
- Other services that require "sticky" identities or stable network endpoints.
Related Concepts¶
- Kubernetes
- Helm
- [[Persistent Volume]]
Sources¶
400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md