In this lab, you'll explore Kubernetes StatefulSets, focusing on managing stateful applications with guarantees about the ordering and uniqueness of a set of Pods.
6 Points:
-
Understand StatefulSets:
-
Update Helm Chart:
- Rename
deployment.ymltostatefulset.yml. - Create a manifest for StatefulSet following the tutorial.
- Test with command:
helm install --dry-run --debug name_of_your_chart path_to_your_chart. - Fix any issues and deploy it.
- Apply best practices by moving values to variables in
values.ymlmeaningfully.
- Rename
4 Points:
-
Research and Documentation:
- Create
14.mdreport. - Include the output of
kubectl get po,sts,svc,pvccommands. - Use
minikube service name_of_your_statefulsetcommand to access your app. - Access the root path of your app from different tabs and modes in your browser.
- Check the content of your file in each pod, e.g.,
kubectl exec pod/demo-0 -- cat visits, and provide the output for all replicas. - Describe and explain differences in the report.
- Create
-
Persistent Storage Validation
-
Delete a pod:
kubectl delete pod app-stateful-0
-
Verify that the PVC and data persist:
kubectl get pvc kubectl exec app-stateful-0 -- cat /data/visits
-
-
Headless Service Access
-
Access pods via DNS:
kubectl exec app-stateful-0 -- nslookup app-stateful-1.app-stateful -
Document DNS resolution in
14.md.
-
-
Monitoring & Alerts
- Add liveness/readiness probes to your StatefulSet.
- Describe in
14.md:- How probes ensure pod health.
- Why they’re critical for stateful apps.
-
Ordering Guarantee and Parallel Operations:
- Explain why ordering guarantees are unnecessary for your app.
- Implement a way to instruct the StatefulSet controller to launch or terminate all Pods in parallel.
List of Requirements:
- Outputs of commands in
14.md. - Results of the "number of visits" command for each pod, with an explanation in
14.md. - Answers to questions in point 2 of
14.md. - Implementation of parallel launch and terminate.
2.5 Points:
-
Apply StatefulSet to Bonus App
- Convert your bonus app’s Helm chart to use a StatefulSet.
-
Explore Update Strategies
-
Implement Rolling Updates:
spec: updateStrategy: type: RollingUpdate rollingUpdate: partition: 1
-
Test Canaries: Update a subset of pods first.
-
Document in
14.md:- Explain
OnDelete,RollingUpdate, and their use cases. - Compare with Deployment update strategies.
- Explain
-
- Maintain clear and organized documentation.
- Use appropriate naming conventions for files and folders.
- For your repository PR, ensure it's from the
lab14branch to the main branch.
Note: Understanding StatefulSets and their optimization is crucial for managing stateful applications in Kubernetes. Explore the bonus tasks to further enhance your skills.