Basics of using Docker-Compose and Kubernetes for NodeJs connecting to Mongo

8/2/2019

I am tasked with using docker-compose to bring up a nodejs express mongoose demo to test some stuff for work. Here is the task sorry i am new to this stuff and I just need to know how to approach this thank you :

Dockerize node-express-mongoose-demo and expose the site on a non-standard port (not 80/443). Do not worry about configuring S3 for image storage as noted in the README.md file. When the app is in production mode it expects the MongoDB connection string to be in the MONGOHQ_URL environment variable.

Add an NGINX container acting as a reverse proxy that routes requests sent to it on port 80/443 to the Node app container. Any supporting services such as MongoDB should also be deployed as Docker containers (Don't use MongoHQ as the app's environment variable suggests).

Use Kubernetes to automate the deployment and management of the containers. Eliminate as many single points of failure for your deployment as possible.

-- ForeverLiunx212
docker-compose
kubernetes

1 Answer

8/4/2019

@ForeverLiunx212 I would recommend you to get started with understanding the stack and running it locally using Docker-Compose, and then set it up on Kubernetes.

Running the docker-compose file locally, docker-compose up -d

This should get your app and mongo up and running, if not debug errors in your containers docker logs CONTAINER_NAME

Deploying your stack to Kubernetes cluster.

  • Setup Mongo as a statefulsets using k8s configs. Once you are comfortable, you can also tryout this Mongo helm chart
  • Setup your application with nginx as reverse proxy
  • Expose your service to external world via ingress controller
-- Mithun Arunan
Source: StackOverflow