From 7adf090750bcab01c675630fe30abcc11d922d1d Mon Sep 17 00:00:00 2001 From: Ramazan Sakin Date: Fri, 11 Sep 2020 09:08:37 +0300 Subject: [PATCH] Update README.md --- README.md | 68 ++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c32176c..b8570b5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Microservics Architecture +# Microservices Architecture -### written by Hitesh Joshi - sendmailtojoshi@gmail.com +### Written by Hitesh Joshi - sendmailtojoshi@gmail.com -This is proof of concept application where I am trying to build a very basic Shopping cart using microservices, the main intent is to setup microservices properly. +This is proof of concept application where I am trying to build a very basic Shopping cart using microservices, the main intent is to set up microservices properly. Due to work and life, this project has taken a back seat. If you want to contribute, feel free to shoot me a PR. @@ -12,27 +12,26 @@ Due to work and life, this project has taken a back seat. If you want to contrib What is done so far - -1. Broken the monolith into smaller microservices. -2. Externalized config to a seprate git repository. +1. Broken the monolith into smaller microservices +2. Externalized config to a seprate git repository 3. Enabled Service Discovery using Netflix Eureka 4. Enabled Circuit breaking in between services using Netflix Hysterix 5. Enabled Circuit monitoring using Hystrix and Turbine dashboards 6. Enabled distributed performance monitoring using Spring Sleuth and Zipkin 7. Enabled Edge server using Netflix Zuul -8. Enabled feign clients. +8. Enabled feign clients 9. Enabled API documentation for individual microservices and through the Edge proxy 10. Used MySql as the database -11. All components can be deployed as docker containers with the attached docker compose file which pre populates the db on startup. -12. Angular SPA deployed on Edge gateway +11. All components can be deployed as docker containers with the attached docker compose file which pre populates the db on startup +12. Angular SPA deployed on Edge gateway: - http://localhost:1101/ - -13. Make sure that you look at the other github repo which has all the externalized config for this project. -14. Swagger Documentation on edge server. +13. Make sure that you look at the other github repo which has all the externalized config for this project +14. Swagger Documentation on edge server What I intend to do - Must DO - Deploy using kubernetes and helm -Look at Load Balancing with Multiple regions , zones - https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-eureka-server.html#spring-cloud-eureka-server-zones-and-regions +Look at Load Balancing with Multiple regions, zones - https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-eureka-server.html#spring-cloud-eureka-server-zones-and-regions 1. Securing the Microservices with OAuth 2 / Spring security. 2. Distributed Log analysis with Elastic Search, logstash and Kibana 3. Distributed Caching with Memacache/Hazelcast. @@ -40,10 +39,7 @@ Look at Load Balancing with Multiple regions , zones - https://cloud.spring.io/s 5. Find a cheap hosting platform and deploy this on cloud :) - - - -### Notes - +### Notes :- - If you are building it without docker, configuration is picked up from github - cloud: config: @@ -53,27 +49,29 @@ Look at Load Balancing with Multiple regions , zones - https://cloud.spring.io/s - If you are building it in docker, this configuration is downloaded and then used. For some reason i was not able to connect config project with github from docker even after setting up ssh. -- In order to run these locally without docker, you need to have a Rabbit MQ and Sql Server started and running as a service. With docker , docker will bring them up. RabbitMQ is needed for zipkin server so that logs are sent by your application to Zipkin. You can replace this RabbitMQ with Kafka. +- In order to run these locally without docker, you need to have a Rabbit MQ and Sql Server started and running as a service. With docker, docker will bring them up. RabbitMQ is needed for zipkin server so that logs are sent by your application to Zipkin. You can replace this RabbitMQ with Kafka. - I have written install.sh which does the job of CI of building and packaging the Spring boot application and put them in a directory from where they can be mounted to docker volumes. - install.sh will also take care of bringing all containers using docker-compose. -All you need is docker , docker-compose, java and maven in the host machine. +All you need is docker, docker-compose, java and maven in the host machine. + +Under the hood this is what happens - - Under the hood this is what happens - 1. Builds all microservices, eureka server, config 2. Brings up mysql 3. Populate mysql with DDL and DML if not done already 4. Bring up config server 5. Bring up Eureka Server -6. Bring up microservices - Eureka clients. -7. Brings up the Zuul Edge gateway. +6. Bring up microservices - Eureka clients +7. Brings up the Zuul Edge gateway 8. Angular SPA - cart UI is bundled with Edge gateway and deployed -9. Add all of the above components into one network so that they can communicate +9. Add all the above components into one network so that they can communicate ### Endpoints :- -Direct web service endpoints +Direct web service endpoints: + - Eureka - http://localhost:1111/eureka - Customer - localhost:2222/customer - Inventory - http://localhost:3333/inventory @@ -83,7 +81,6 @@ Direct web service endpoints - Endpoint with a Circuit breaker and Hystrix fallback - http://localhost:2222/customers/1/orders - ### URL's through edge proxy :- - http://localhost:1101/customer-service/customers - http://localhost:1101/invoice-service/invoice @@ -94,6 +91,7 @@ and so on... Zuul Routes - You can add Filters on the Zuul Proxy layer. This examples we have not added any. Monitor project- + ### Hystrix Monitor details :- Hystrix Monitor - We need to provide the application that needs to be montored. Please input in Hystrix Dashboard - @@ -154,10 +152,8 @@ https://github.com/hiteshjoshi1/microservice-docker-cart-config ``` - - -### NOTE -If you want to use the same config, clone this repo and then change the gut URL to your cloned repo in the config/ resources For the config server to be able to fetch property from github , setup SSH access to your github account. +### NOTE :- +If you want to use the same config, clone this repo and then change the gut URL to your cloned repo in the config/ resources For the config server to be able to fetch property from github, setup SSH access to your github account. To see corresponding docker profiles, change the profile at the end as - - http://localhost:5555/inventory-service/docker @@ -178,13 +174,13 @@ Old -> To start the Mysql container:
docker run --name docker-mysql -e MYSQL_ROOT_PASSWORD=test -P -d mysql -To populate the data , go to sql command prompt with +To populate the data, go to sql command prompt with sudo docker run -it --link docker-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"' Run init.sql -Then Create a network , this should also be ideally part of docker compose +Then Create a network, this should also be ideally part of docker compose
sudo docker network create microservicesnet @@ -218,8 +214,7 @@ The Java 8 base image used to build the microservice containers is also checked The base image can be built using -
docker build -t microservice/baseserviceimg .
- +
docker build -t microservice/baseserviceimg
___________________________________________________________________________________________________________________________ @@ -231,14 +226,15 @@ Building individual containers without docker compose To Build the image from Docker File - Custom image as specified in the Dockerfile ---> (Note the .)
-1. Build(Or Rebuilding) Service Discovery Customer, Inventory , Invoice from the docker file . +1. Build(Or Rebuilding) Service Discovery Customer, Inventory, Invoice from the docker file.
    -
  • docker build -t microservice/customer . -
  • docker build -t microservice/inventory . -
  • docker build -t microservice/invoice . +
  • docker build -t microservice/customer +
  • docker build -t microservice/inventory +
  • docker build -t microservice/invoice
+ Building a container happens once, once it is built you can run it from the same folder and give it a name. To Run the Custom Image, notice the linkage to the mysql container for microservices-->