microsoft / microsoft/WhatTheHack

IntroToAKS: MongoDB should use StatefulSets instead of Deployments

Open
#282 7 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.