⬅️ Back to Kubernetes overview
Create StatefulSet based on the example
kubectl apply -f kubernetes/statefulset/resources.yamlCheck the result if the deployment worked by visiting http://localhost:30888
📝 Why is there a nginx error page displayed?
Inspect the resources that have been created. What about their name?
kubectl get pods
kubectl get service
kubectl get persistentvolumeclaims
kubectl get persistentvolumeWhat are these volumes we just used/created?
Explain PersistentVolumes and PersistentVolumeClaims as well as retention policies.
💡 Retention policies should always be checked before depleting any PersistentVolume or PersistentVolumeClaim
So what about storage classes?
kubectl get storageclass
kubectl get storageclass hostpath -o yaml- 💡 Visit https://kubernetes.io/docs/concepts/storage/storage-classes/ for more information
- 💡
StorageClasses will be one of the
Let's copy different content to the volumes to see the effect
kubectl cp kubernetes/statefulset/index-light.html web-0:/usr/share/nginx/html/index.html
kubectl cp kubernetes/statefulset/index-dark.html web-1:/usr/share/nginx/html/index.htmlCheck the result of the change by going to http://localhost:30888 It might take a few (or even many) tries to get to both instances
As this is persistent storage, this change is permanent in case of a pod restart
kubectl delete pod web-0💡 Service special case: Headless service to give unique but deterministic DNS names for each Pod.
- 📝 What happens with the
pvif you delete theStatefulSet? - 📝 Create a custom
pvcand use it in aDeployment. What is the difference compared to aStatefulSet?