Deploy Mongodb and NodeJS with Kubernetes

6/6/2020

I am learning Kubernetes and finding some suggestions about deploying my application.

My application background:

Backend: NodeJS

Frontend: ReactJS

Database: MongoDB (Just run mongod to start instead of using MongoDB cloud services)

I already know how to use Docker compose to deploy the application in single node.

And now I want to deploy the application with Kubernetes (3 nodes).

So how to deploy MongoDB and make sure the MongoDB data is synchronize in 3 nodes?

I have researched some information about this and I am confused on some keywords.

E.g. Deploy a Standalone MongoDB Instance, StatefulSet, ...

Are this information / articles suitable for my situation? or do you know any information about this? Thanks!

-- potato
kubernetes
mongodb
node.js

2 Answers

2/9/2022

You can create helm charts for your apps for deployment -

  • Create Dockerfile for your app, make sure you copy the build that was created using npm build
  • Push to dockerhub or any other registry like ACR or ECR
  • Add the image tags in helm deployments & pass values from values.yaml

For MongoDb deployment, use this chart https://github.com/bitnami/charts/tree/master/bitnami/mongodb

-- Sapna
Source: StackOverflow

6/6/2020

You can install mongodb using this helm chart.

You can start the MongoDB chart in replica set mode with the following parameter: replicaSet.enabled=true

Some characteristics of this chart are:

Each of the participants in the replication has a fixed stateful set so you always know where to find the primary, secondary or arbiter nodes. The number of secondary and arbiter nodes can be scaled out independently. Easy to move an application from using a standalone MongoDB server to use a replica set.

See here to learn configuration and installation details

-- hoque
Source: StackOverflow