Skip to content

info-vivekranjan/mern_app_deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚀 MERN Application Deployment on Kubernetes

This project demonstrates deploying a MERN (MongoDB, Express, React/Next.js, Node.js) application on a Kubernetes cluster using manifests.


📦 Prerequisites

Ensure you have the following installed:

  • Kubernetes cluster (Minikube / EKS / any)
  • kubectl CLI
  • Docker (for building images, if needed)
  • Minikube (for local setup)

⚙️ Environment Configuration

Before deployment, update the required environment variables:

🔹 Frontend

Set the API base URL:

NEXT_PUBLIC_API_URL=http://myapp.local

🔹 Backend

Update the following:

MONGO_URI=<your-mongodb-atlas-uri>
PORT=5000

⚠️ Important: Update the MONGO_URI value inside backend_secret.yaml with your MongoDB Atlas connection string.


🚀 Deployment Steps

1. Create Namespace

kubectl create namespace mern-docker-app

2. Apply Kubernetes Manifests

cd mern_app_deployment/k8s_manifest
kubectl apply -f .

3. Verify Resources

kubectl get all -n mern-docker-app

🌐 Ingress Setup (Required)

Make sure an Ingress Controller is installed in your cluster.

✅ For Minikube:

minikube start
minikube addons enable ingress
kubectl get pods -n ingress-nginx

Ensure the ingress controller pod is in Running state.


🌍 Local Domain Configuration

This project uses a custom domain for local access:

http://myapp.local

👉 Map domain in /etc/hosts

  1. Get Minikube IP:
minikube ip
  1. Add entry to /etc/hosts:
<MINIKUBE_IP> myapp.local

🧪 Access the Application

Once everything is set up, access the app in your browser:

http://myapp.local

🛠️ Troubleshooting

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.yaml is correctly configured
    • Confirm host (myapp.local) matches /etc/hosts
    • Check path rules and pathType

📌 Notes

  • The domain myapp.local is 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.

About

This project demonstrates deploying a MERN (MongoDB, Express, React/Next.js, Node.js) application on a Kubernetes cluster using manifests.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors