Microservices Architecture with Kubernetes, Docker, MongoDB, Prometheus, Grafana, Ingress, Helm, and CI/CD
flowchart TD
subgraph Users
A["User"]
end
subgraph Ingress["NGINX Ingress (microservices.local)"]
B["Ingress Controller"]
end
subgraph Services["Microservices"]
C["User Service"]
D["Product Service"]
E["Order Service"]
end
subgraph DB["MongoDB"]
F["MongoDB"]
end
subgraph Monitoring["Monitoring"]
G["Prometheus"]
H["Grafana"]
end
subgraph CI["CI/CD"]
I["GitHub Actions / Jenkins"]
end
A --> B
B --> C
B --> D
B --> E
C --> F
D --> F
E --> F
G --> C
G --> D
G --> E
H --> G
I --> B
I --> C
I --> D
I --> E
I --> F
I --> G
I --> H
This project demonstrates a robust microservices architecture using Docker and Kubernetes, featuring:
- Three Node.js microservices (User, Product, Order) with MongoDB integration
- Kubernetes manifests and a Helm chart for easy deployment
- NGINX Ingress for API gateway/routing
- Monitoring with Prometheus and Grafana
- Automated CI/CD with Jenkins and GitHub Actions
user-service/ # User microservice (Node.js, MongoDB)
product-service/ # Product microservice (Node.js, MongoDB)
order-service/ # Order microservice (Node.js, MongoDB)
k8s/ # Kubernetes manifests (Deployments, Services, Ingress, MongoDB)
monitoring/ # Prometheus, Grafana configs and manifests
ci-cd/ # Jenkins pipeline (Jenkinsfile)
helm/ # Helm chart for the entire stack
.github/workflows/ # GitHub Actions workflow for CI/CD
- Docker
- Kubernetes (Minikube, kind, or a cloud provider)
- kubectl
- Node.js (for local development)
- Jenkins (for CI/CD)
- Helm
cd user-service && npm install && npm start
cd product-service && npm install && npm start
cd order-service && npm install && npm start
docker build -t user-service:latest ./user-service
docker build -t product-service:latest ./product-service
docker build -t order-service:latest ./order-service
kubectl apply -f k8s/
kubectl apply -f monitoring/
helm upgrade --install microservices-architecture ./helm
- Ingress: Add
127.0.0.1 microservices.localto your/etc/hostsand usehttp://microservices.local/user/,/product/,/order/ - Prometheus:
kubectl port-forward svc/prometheus 9090:9090 - Grafana:
kubectl port-forward svc/grafana 3000:3000
- Jenkins: Use
ci-cd/Jenkinsfile - GitHub Actions: See
.github/workflows/ci-cd.yml - Configure Docker Hub and Kubeconfig secrets for GitHub Actions
- Prometheus scrapes metrics from all microservices
- Grafana provides dashboards for real-time monitoring
- Customize
monitoring/prometheus-config.yamlor Helm values to add more scrape targets
- Each microservice is independently deployable and scalable
- Use health checks (
/healthendpoint) for readiness and liveness probes - Centralized logging and monitoring for observability
- Automated CI/CD for rapid, reliable deployments
- Secure secrets and sensitive data using Kubernetes Secrets (not included in this public repo)
- Add more microservices by copying the template structure
- Integrate with databases or external APIs as needed
- Enhance security with RBAC, network policies, and TLS