Hands-on with StatefulSets
In this section, you’ll deploy a working StatefulSet.
The demos are designed and tested on Google Kubernetes Engine (GKE) and a local Docker Desktop cluster. If your cluster is on a different cloud, you’ll have to use a different StorageClass. We’ll tell you when to do this.
If you haven’t already done so, run the following command to clone the book’s GitHub repo.
$ git clone https://github.com/nigelpoulton/TheK8sBook.git
Run all remaining commands from within the statefulsets folder.
You’re about to deploy the following three objects:
- A StorageClass
- A headless Service
- A StatefulSet
To make things easier to follow, you’ll deploy and inspect each object individually. However, it’s possible to group them into a single YAML file and deploy them with a single command (see app.yml in the statefulsets folder of the repo).
Deploy the StorageClass
StatefulSets need to create volumes dynamically...