Simple microservices POC based on the Spring Cloud and Java 18, to try microservices architecture patterns and technologies.
Project structure:
- apigw - spring cloud gateway
- commons - common microservices code
- config-server - spring cloud config server, for storing services properties in one place
- consumer - consumer service
- eureka-server - discovery service, for simple communication between services
- fraud - service for checking if the consumer is fraudster
We need to add a host mapping for keycloak. It is crucial because keycloak is relay on the host. If you will run one service from localhost and keycloak from docker - authentication will not work. Because the keycloak host on docker will be: http://keycloak but in browser it will be: http://locahost
Add next items to the hosts
sudo nano /etc/hosts
127.0.0.1 keycloak
For customer and fraud service we need to create a databases(it will be automated in future updates). It should be customer and fraud databases.
To run docker containers, just run from the docker:
docker compose up
- add a docker for postgresql - https://github.com/dtimchenko/custom-microservices-project/commit/5f17c642ec2277707e532a94a03a5df968403964
- add a docker-compose for all microservices - https://github.com/dtimchenko/custom-microservices-project/commit/39a93cc67dd5630aedd84afc4ed5b0713a56ef27
- add a dockerfile to the project
docker build --tag=<repository-name> .
- to build an imagedocker push <repository-name>
- push an image to the dockerhub
To update service properties dynamically (without service redeploy) you need:
- update properties on config-server repo (https://github.com/dtimchenko/temp-repo.git/config-server/src/main/resources/applications/)
- POST http://localhost:8010/actuator/busrefresh (where localhost:8010 is a config-server address)
- Init maven parent pom - https://github.com/dtimchenko/custom-microservices-project/commit/b5d15058b41bde97fd809fb7e39e3f48dd5deb43
- Add a docker-compose for postgresql - https://github.com/dtimchenko/custom-microservices-project/commit/5f17c642ec2277707e532a94a03a5df968403964
- Add Eureka Server - https://github.com/dtimchenko/custom-microservices-project/commit/e615453423bcb8b4326f0dc93fa4413fd5d8e549
- Add Eureka Clients - https://github.com/dtimchenko/custom-microservices-project/commit/27f3273c53bdba149c7e5dc040c8cf382db17575
- Add Eureka Clients RestTemplate Communication - https://github.com/dtimchenko/custom-microservices-project/commit/e6b61fcbfa9dd67ea1e260f50191cdcaaca9626a
- Add Eureka Clients Feign Communication - https://github.com/dtimchenko/custom-microservices-project/commit/4c894dcf2d9b13c089df0ebe9cadee3b24f4ff85
- Add GRPC and Protobuf - https://github.com/dtimchenko/custom-microservices-project/commit/103a6c4a3927a4e525dddb8f9117c7e71f11d70b
- Add hystrix Circuit Breaker - https://github.com/dtimchenko/custom-microservices-project/commit/8a78055c87140edf80f39945b5e4766e6e84be42
- Add resilience4j Circuit Breaker - https://github.com/dtimchenko/custom-microservices-project/commit/3f266435014ba94c79af166f20964ea5404ec2bc
- Add resilience4j Retry - https://github.com/dtimchenko/custom-microservices-project/commit/47fb688aec682ecf350590fa0c6e4ceffc7eafbb
- Add application/xml API support - https://github.com/dtimchenko/custom-microservices-project/commit/4c894dcf2d9b13c089df0ebe9cadee3b24f4ff85
- Add Request Validation - https://github.com/dtimchenko/custom-microservices-project/commit/301886c3d5863319f1478faa2dc19edea89c4ea4
- Add API Gateway - https://github.com/dtimchenko/custom-microservices-project/commit/dd4b2bf1b945e502a396321fd94be9c8735df816
- Add Manual Route for API Gateway - https://github.com/dtimchenko/custom-microservices-project/commit/f2c1aa71e92c0cf7c2216e2058b7434e05968b22
- Add Spring Gateway LoadBalancer - https://github.com/dtimchenko/custom-microservices-project/commit/9791ca86f585bee408707ba98173034bed011297
- Add Gateway Authorization filter - https://github.com/dtimchenko/custom-microservices-project/commit/144531f83c5ca2ecc919b4abdc587101e1915272
- Add Gateway Global Post/Pre Filters - https://github.com/dtimchenko/custom-microservices-project/commit/22f448c14c22c20a666e69442f03b16ed6fa9f68
- Add Spring Security - https://github.com/dtimchenko/custom-microservices-project/commit/da4211d999f0cd68002335439cc569d10714bc19
- Add Spring Security Password Encryption - https://github.com/dtimchenko/custom-microservices-project/commit/3fd5d13029b661f05df8b77e416c8dbf6fc48f34
- Add Spring Security JWT - https://github.com/dtimchenko/custom-microservices-project/commit/1b3504a5e6d847ead3825d4aa638beee7ad796ae
- Add a JWT refresh_token - https://github.com/dtimchenko/custom-microservices-project/commit/28ab1ba9de5bfdc632ff774b3911e3954b6453a1
- Add Method Level Security - https://github.com/dtimchenko/custom-microservices-project/commit/cceea3db70d74f9d6652bb5b281f0f96fdf4fa47
- Add Keycloak Server - https://github.com/dtimchenko/custom-microservices-project/commit/cf828c9f0b7f040ecd40d819ddfe30a82b45939e
- Keycloak Docker Fix - https://github.com/dtimchenko/custom-microservices-project/commit/ac98adec2113feb08a960a69552133e263b48b5d
- Add OAuth2 Token to a Feign-Client - https://github.com/dtimchenko/custom-microservices-project/commit/5a0c954c857af834354abdc03a57b7ec6e86497e
- Add a Spring Cloud Config Server - https://github.com/dtimchenko/custom-microservices-project/commit/fbf1b88fb8f834a7705b329d2f77d514dc80e18a
- Add Config Server Shared Properties - https://github.com/dtimchenko/custom-microservices-project/commit/e669f370c7615f436f7febe3f33bff635ee94c6b
- Add zipkin and spring sleuth tracing - https://github.com/dtimchenko/custom-microservices-project/commit/3401c18099864ace8e30431f325596cc86e3f7b0
- Update services properties dynamically - https://github.com/dtimchenko/custom-microservices-project/commit/31574d0d1f97345eb1fd02674de438daac12f65f
- Add ELK logging with Filebeats - https://github.com/dtimchenko/custom-microservices-project/commit/0f2646e2bcb16f75dfc86e4a448eef3d53f23763
- Add Kafka buffer to ELK logs - https://github.com/dtimchenko/custom-microservices-project/commit/81203e61caaced7c68d3804cd4e776105e64d5e7
- Add monitoring with: Micrometer, Prometheus and Grafana - https://github.com/dtimchenko/custom-microservices-project/commit/45091411e6a29a5c0cc0eb61434b629c46c3f5ff
- Add Properties SYMMETRIC encryption and decryption - https://github.com/dtimchenko/custom-microservices-project/commit/0795f4049a64c766f7f9ab1d9677caee9148d9ee
to encrypt a property just send a POST to http://localhost:8010/encrypt (where http://localhost:8010 is the config-server's endpoint)