Microservices-Spring-Boot-ELK
Spring boot microservices with Authentication and centralized log with ELK
Prerequisites
- Java 8
- JPA Mysql
- Mongo DB
- Spring Boot Actuator
- Dev Tools
- Lombok
- Eureka
- Zuul
- Zipkin
- Sleuth
- JWT
- Elasticsearch-Logstash-Kibana
Setup MySQL
Import dump-app_db.sql to your MySQL
Architecture
Login to get bearer token from the authentication endpoint /auth/login . Then send a request to access the protected microservices. Zuul Service act like Gateway which does central authentication, redirect an incoming request to other microservices.
Eureka Server
Holds the information about all client-service applications.
Common Service
Configure jwt variable
Authentication Service
Validate user credential with phoneNumber or/and email and if validate then generate token, otherwise throw exception
User Service
Create microservices that responsible to handle CRUD operation of user.
Product Service
Create microservices that responsible to handle CRUD operation of product.
Zuul Service
Create Gateway-Service (Zuul proxy) Application ,register it in Eureka server, validate token, and centralize authentication incoming request.
Elasticsearch-Logstash-Kibana
Collect and centralized logging in three open source project for analysis in various environments, search indexes, visualize data with charts and graphs
Zipkin
Measure where service has spent more time.
Deployment Strategy with Docker
Interact container with each other using Docker Networking
Create Docker Networking to allow multiple containers to communicate with each other.
docker network create interact-spring-boot-services
Build image for each microservices
1. Eureka Service
mvn clean install package -DskipTests
docker image build -t eureka-service --rm=true .
2. Common Service
mvn clean install package -DskipTests
docker image build -t commons-service --rm=true .
3. Authentication Service
mvn clean install package -DskipTests
docker image build -t authentication-service --rm=true .
4. User Service
mvn clean install package -DskipTests
docker image build -t master-user-service --rm=true .
5. Product Service
mvn clean install package -DskipTests
docker image build -t master-product-service --rm=true .
6. Zuul Service
mvn clean install package -DskipTests
docker image build -t zuul-service --rm=true .
Create and run container using Docker Compose
docker-compose up --build
Sample Payload
- Login request
- Register User
- Update User
- Get User By Id
- Get Product By Id
- Collect log by ELK
- Measure request with Zipkin