This project was created for educational purposes and to consolidate the acquired knowledge.
Keep in mind that the implementation is ongoing and some modules may work with bugs.
This demo shows a working sample of microservices architecture using ASP.NET Core. It covers how to create microservices, how to create API gateways using Ocelot and how to deploy microservices using Docker containers.
The fastest and easiest way to run this project is a Kubernates Cluster. You just need to install Docker Desktop and Minikube tools. Instead of building sources you can use latest version of images from public Docker Hub registry (romanbilyak). Go to the folder deploy and run run.ps1 script with specified registry parameter.
PowerShell:
.\run.ps1 -registry 'romanbilyak'
CMD:
run -registry 'romanbilyak'
Other methods of running this project are described below:
Prerequisites:
Go to the folder deploy and run run.ps1 or run.cmd script.
PowerShell:
.\run.ps1 -nodes 2 -cpus 4 -memory 4096 -r 'localhost:5000' -t 'v1.0' -b
CMD:
run -nodes 2 -cpus 4 -memory 4096 -r 'localhost:5000' -t 'v1.0' -b
Param | Short Form | Default | Description |
---|---|---|---|
-nodes | -n | 1 | Number of nodes. |
-cpus | -c | 2 | Number of CPUs allocated to Kubernetes. |
-memory | -m | 2048 | Amount of RAM to allocate to Kubernetes. |
-registry | -r | '' | Name of docker images registry. |
-tag | -t | '' | Tag of images. |
-build | -b | false | Flag to build images. |
The script will:
-
Start Kubernates Cluster localy using Minikube.
-
Build microservices images.
-
Push images to specified registry.
In a case when registry is not specified images will be pushed into Docker Deamon of cluster.
In a case when registry is set to 'localhost:5000' local registry inside cluster will be created.
-
Deploy services to local Kubernates Cluster.
-
Expose gateway service and start Kubernates Cluster dashboard.
Go to http://localhost to view gateway methods.
Prerequisites:
-
.Net 7.0 (Included in Visual Studio Community 2022 v17.4.4)
-
Go to the folder deploy\docker-compose-infrastructure and run the following docker-compose command in CMD or PowerShell:
docker-compose -f docker-compose.yml -f docker-compose.override.yml up
-
Go to the folder deploy\docker-compose and run the following docker-compose command in CMD or PowerShell:
docker-compose -f docker-compose.yml -f docker-compose.override.yml up
Prerequisites:
Set gateway and microservices as startup projects. Your can also run the docker-compose-infrastructure project instead of installing and configuring infrastructure services by yourself.
Visual Studio | Local Docker Host | Kubernates Cluster | |
---|---|---|---|
angular-ui | localhost:7001 | localhost:9001 | |
react-ui | localhost:7002 | localhost:9002 | |
gateway | localhost:7100 | localhost:9100 | localhost |
identity-server | localhost:7111 | localhost:9111 | |
identity-service | localhost:7201 | localhost:9201 | |
movie-service | localhost:7202 | localhost:9202 | |
review-service | localhost:7203 | localhost:9203 | |
payment-service | localhost:7204 | localhost:9204 | |
test-service | localhost:7205 | localhost:9205 |
-
applications -
-
core -
-
deploy -
-
microservices -
-
tests -
This project implements NLayer architecture and Domain Driven Design
-
Database
- EF Core
-
Ast.Net Core
-
Entities
-
Specifications
-
Validation Rules
-
Managers
- Database contexts
- Application services
Root layer for microservice's layers
-
Controllers
-
View Models
- Unit Tests