This repository contains a set of microservices implemented in Node.js, along with a React client. The microservices include users, tasks, and auth, each of which has a Dockerfile for containerization and Kubernetes configuration for deployment.
- Node.js (v14+)
- Docker
- Kubernetes (minikube or a Kubernetes cluster)
-
Clone this repository:
git clone https://github.com/mmmihaeel/node-microservices-docker-kubernetes.git cd node-microservices-docker-kubernetes cd users-api npm install cd ../tasks-ap npm install cd ../auth-api npm install cd ../client npm install
-
Run with docker: Start the microservices and client using Docker Compose:
docker-compose build docker-compose up
Apply Kubernetes configurations for each microservice and the client:
kubectl apply -f kubernetes/users-deployment.yaml
kubectl apply -f kubernetes/tasks-deployment.yaml
kubectl apply -f kubernetes/auth-deployment.yaml
kubectl apply -f kubernetes/client-deployment.yamlExpose the services:
kubectl expose deployment users-deployment --type=LoadBalancer --port=80
kubectl expose deployment tasks-deployment --type=LoadBalancer --port=80
kubectl expose deployment auth-deployment --type=LoadBalancer --port=80
kubectl expose deployment client-deployment --type=LoadBalancer --port=80Replace LoadBalancer with the appropriate service type for your environment.
node-microservices-docker-kubernetes/
├── users-api/
│ ├── Dockerfile
│ ├── .env.dev # Users microservice development environment
│ ├── .env.prod # Users microservice production environment
│ ├── users-app.js
│ │ └── ... # Users microservice source files
├── tasks-api/
│ ├── Dockerfile
│ ├── .env.dev # Tasks microservice development environment
│ ├── .env.prod # Tasks microservice production environment
│ ├── tasks-app.js
│ │ └── ... # Tasks microservice source files
├── auth-api/
│ ├── Dockerfile
│ ├── .env.dev # Auth microservice development environment
│ ├── .env.prod # Auth microservice production environment
│ ├── auth-app.js
│ │ └── ... # Auth microservice source files
├── client/
│ ├── Dockerfile
│ ├── public/
│ ├── conf/ # Nginx production config for React client
│ ├── src/
│ │ └── ... # React client source files
├── kubernetes/
│ ├── users-deployment.yaml
│ ├── tasks-deployment.yaml
│ ├── auth-deployment.yaml
│ ├── configmap.yaml # kuberenetes env
│ ├── client-deployment.yaml
├── docker-compose.yml
├── .env # docker env
└── README.mdContributions are welcome! Please follow the standard GitHub fork and pull request workflow.
This project is licensed under the MIT License.