Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Microservics Architecture
# Microservices Architecture

### written by Hitesh Joshi - [email protected]
### Written by Hitesh Joshi - [email protected]


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.

Expand All @@ -12,38 +12,34 @@ 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.
4. CI/CD pipeline
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:
Expand All @@ -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 <b>install.sh</b> 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.
- <b>install.sh</b> 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
Expand All @@ -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
Expand All @@ -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 -
Expand Down Expand Up @@ -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
Expand All @@ -178,13 +174,13 @@ Old ->
To start the Mysql container: <BR>
<b><code>docker run --name docker-mysql -e MYSQL_ROOT_PASSWORD=test -P -d mysql</code></b>

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

<div>
<b><code>sudo docker network create microservicesnet</b></code>
Expand Down Expand Up @@ -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

<div><b><code>docker build -t microservice/baseserviceimg .</code></b></div>

<div><b><code>docker build -t microservice/baseserviceimg</code></b></div>


___________________________________________________________________________________________________________________________
Expand All @@ -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 .) <br>

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.
<div>
<ul>
<li><b><code>docker build -t microservice/customer . </code></b>
<li><b><code>docker build -t microservice/inventory . </code></b>
<li><b><code>docker build -t microservice/invoice . </code></b>
<li><b><code>docker build -t microservice/customer </code></b>
<li><b><code>docker build -t microservice/inventory </code></b>
<li><b><code>docker build -t microservice/invoice </code></b>
</ul>
</div>

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--><br>
Expand Down