Deploying nodejs express backend application with MongoDB database on a kubernetes cluster.
kubernetes cluster runnig
Creating a cluster with kubeadm
- 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 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