July 2019
Intermediate to advanced
502 pages
14h
English
At its core, a StatefulSet is a controller that manages a set of pods with some extra properties, such as ordering and uniqueness. The StatefulSet allows its set of pods to be deployed and scaled, while preserving their special properties. StatefulSets reached general availability (GA) status in Kubernetes 1.9. You can think of a StatefulSet as a souped-up deployment. Let's take a look at a sample StatefulSet for the user service, which uses a relational PostgresDB as its data store:
apiVersion: apps/v1kind: StatefulSetmetadata: name: user-dbspec: selector: matchLabels: svc: user app: postgres serviceName: user-db replicas: 1 template: metadata: labels: svc: user app: postgres spec: terminationGracePeriodSeconds: ...