Skip to content

elmansey/Deploy-nodejs-mongodb-app-on-k8s

Repository files navigation

Deploy-nodejs-mongodb-app-on-k8s

Deploying nodejs express backend application with MongoDB database on a kubernetes cluster.

Prerequisite

kubernetes cluster runnig

  • In my case I used kubeadm to install kubernetes cluster in three ubuntu aws EC2 image

image

Creating a cluster with kubeadm

Steps

  • Create persistent volume and persistent volume claim to persist Mongodb data
kubectl apply -f persistent-volume.yaml
kubectl apply -f mongodb-persistent-volume-claim.yaml
  • Create configMap and secret for MongoDB metadat and Credentials
kubectl apply -f config.yaml
  • Create MongoDB Deployment and service
kubectl apply -f mongodb.yaml
  • Create Deployment for nodejs backend app
kubectl apply -f express-nodejs.yaml
  • Create service for nodejs backend app
kubectl apply -f node-app-svc.yaml
  • install Nginx Ingress Controller in Kubernetes by using helm to allow me apply ingress in cluster
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx  ingress-nginx/ingress-nginx
  • Create external service (LoadBalancer) image

  • Create Ingress to make app accessible from outside cluster and connect it with loadBalancer

  kubectl apply -f ingress-class.yml
  kubectl apply -f express-node-app-ingress.yaml
  • Use the LoadBalancer dns name to access the service or hostname

image

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors