POC app of the Spring Cloud microservices architecture written built with DDD and hexagonal architecture.
Module | Ports |
---|---|
Spring Cloud Config server | 8888 |
Eureka server | 8761 |
Gateway service | 8080 |
Simulation service | 8099 |
User services | 8100 - 8199 |
Post services | 8200 - 8299 |
Comment services | 8300 - 8399 |
Module | Ports |
---|---|
Sonar | 9100 |
Zipkin server | 9411 |
Kafka | 29092 |
Prometheus | 9090 |
Grafana | 9091 |
mvn verify sonar:sonar -Dsonar.host.url=http://localhost:9000
verify
step is needed to get sonar-project.properties file by maven plugin
Zipkin gathers traces of communication between services.
For K8S environment Zipkin uses HTTP communication: http://localhost:9411.
For dev and mock profiles, apps and Zipkin uses Kafka topic zipkin
to gather traces. Kafka has to be started in docker
compose.
Offset Explorer can be connected to the Kafka cluster run in docker compose with the following way:
Monitoring consists of:
mvn clean package
Run script
.\build_images.sh
or use spring boot plugin for maven (the latest image version is set by default):
clean package spring-boot:build-image -DskipTests
WARNING: images built with spring boot have problems in kubernetes - memory issue
Warning: to use spring-cloud-config server without git config source, it should be run with native
profile
docker-compose -up
\docker\blog.yml
Docker compose environment components:
Go to /k8s/blog/
where build scripts are defined and run commands:
kubectl apply -f zipkin-service.yaml
kubectl apply -f user-service.yaml
kubectl apply -f post-service.yaml
kubectl apply -f gateway-service.yaml
kubectl apply -f comment-service.yaml
kubectl apply -f simulation-service.yaml
Standard K8S service registry and config (ConfigMap and Secrets) are used.
DDD shall be used here based on that: https://wkrzywiec.medium.com/ports-adapters-architecture-on-example-19cab9e93be7 and book. Use ports and adapters (application, core without frameworks, infrastructure as connectors and ports implementation)
*.application
- input interfaces like: REST API controllers, event listeners, schedulers
.controller
- REST controllers.scheduler
- schedulers.listener
- external event listeners.service
- application services/facades with transactions integrates all application components. They contain only flow of use cases and all the business logic is performed in domain port.
Cache also should be here. Should use only incoming ports on a domian.*.core
- core domain package, should contain only clean Java code without frameworks and operates on domain objects (ports, commands) without implementation.
.model
- domain model: aggregates and value objects. Business logic in the scope of one aggregate should be in the aggregate. .command
- command objects used in incoming ports.event
- domain events.exception
- exceptions.port.incoming
- interfaces describing ports incoming to the domain model. Ports are gathered in the Facade or domain service..port.outgoing
- interfaces describing outgoing ports used by domain service (facade).service
- it contains two types of services:*.infrastructure
- infrastructure is technology/framework related part of the app. Adapters (ports implementations) and beans config.
.adapter
- adapters - ports implementations.config
- configuration of the adapter beans. All dependencies should be injected here to not infect domain part.