Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Automating MongoDB Replica set configuration on Kubernetes

I am creating a MongoDB cluster on Kubernetes using Stateful sets. I have 3 mongo replicas configured in my Stateful set.

Now I create Stateful set and service using just one command

kubectl create -f mongo-stateful.yaml

Then I use the mongo client to initiate mongo replica set members.

rs.initiate(
   {
      _id: "replicaset1",
      version: 1,
      members: [
         { _id: 0, host:port1 },
         { _id: 1, host : host:port1 },
         { _id: 2, host : host:port1  }
      ]
   }
)

All of this works except I would like to automate this step of configuring replica set members.

My questions is whether this step can be automated and if we can add this to the yaml file?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

This might be what you're looking for:

http://blog.kubernetes.io/2017/01/running-mongodb-on-kubernetes-with-statefulsets.html

over 4 years ago · Santiago Trujillo Report

0

Yes, it is possible, you have several choices:

  1. Use the sidecar approach as specified by @tzik, then you don't need to do much in your code
  2. Use the kubernetes lifecycle.postInstall feature to implement the clustering on your own (this is a bit tricky, because postInstall runs on each statefulset member)
  3. Use if you decide to use helm to manage your k8s deployments, then you can use helm post-install hooks to initiate your mongodb cluster.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!