This project demonstrates deploying a MERN (MongoDB, Express, React/Next.js, Node.js) application on a Kubernetes cluster using manifests.
Ensure you have the following installed:
- Kubernetes cluster (Minikube / EKS / any)
- kubectl CLI
- Docker (for building images, if needed)
- Minikube (for local setup)
Before deployment, update the required environment variables:
Set the API base URL:
NEXT_PUBLIC_API_URL=http://myapp.local
Update the following:
MONGO_URI=<your-mongodb-atlas-uri>
PORT=5000
⚠️ Important: Update theMONGO_URIvalue insidebackend_secret.yamlwith your MongoDB Atlas connection string.
kubectl create namespace mern-docker-app
cd mern_app_deployment/k8s_manifest
kubectl apply -f .
kubectl get all -n mern-docker-app
Make sure an Ingress Controller is installed in your cluster.
minikube start
minikube addons enable ingress
kubectl get pods -n ingress-nginx
Ensure the ingress controller pod is in Running state.
This project uses a custom domain for local access:
http://myapp.local
- Get Minikube IP:
minikube ip
- Add entry to
/etc/hosts:
<MINIKUBE_IP> myapp.local
Once everything is set up, access the app in your browser:
http://myapp.local
If the application is not working:
-
Check all resources:
kubectl get all -n mern-docker-app -
Inspect logs:
kubectl logs <pod-name> -n mern-docker-app -
Verify Ingress configuration:
- Ensure
ingress.yamlis correctly configured - Confirm host (
myapp.local) matches/etc/hosts - Check path rules and
pathType
- Ensure
- The domain
myapp.localis hardcoded for local development. - For production deployments, use a proper domain with DNS configuration.
- Ensure secrets are not committed with real credentials in public repositories.