microsoft / microsoft/WhatTheHack
IntroToAKS: MongoDB should use StatefulSets instead of Deployments
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.9k
- Forks
- 886
- PR merge metrics
- No merged PRs in 30d
Description
To be aligned with best practices for stateful applications, MongoDB should be deployed as a StatefulSet (of one replica) rather than a Deployment.
I have encountered some issues ('race conditions') when debugging & troubleshooting mongodb if it has been deployed as a deployment. Specifically, you can't do any sort of rolling update, or restart (kubectl rollout restart deployment mongodb), as the new pod will never be able to make a claim on the pvc while the old pod is hanging around.
Using a statefulset overcomes this problem. I've tested it using a stateful set and I will be pushing a PR with the revisions necessary to support a stateful set in this hack.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the IntroToAKS MongoDB deployment manifest and reviewing how its Deployment, replica count, and PVC are configured. Replace the one-replica Deployment with a StatefulSet and verify that MongoDB rollout or restart operations no longer encounter the PVC claim race described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kubernetes, mongodb
- Domain
- databases, infrastructure
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100