Let's define a simple StatefulSet to deploy nginx "hello-nginx-statefulset":
If you are using Kubernetes on Docker Desktop, you will need to adjust the volumeClaimTemplates section as following:
If you are using Kubernetes on Docker Desktop, you also need to define a Persistent Volume (hostPath) for each Pod replica.
For more details, see
Volumes.
Let's define the headless Service:
Let's create the Persistent Volumes (again this is needed only for Kubernetes on Docker Desktop):
View the Persistent Volumes (the STATUS is Available):
Let's create the StatefulSet:
Check the Pods creation:
Check the Persistent Volume Claims:
Check again the Persistent Volumes (the STATUS should be Bound now):
Let's create the headless Service:
Check the headless Service: