Microservices: Developing a Microservice Architecture ( .Net Core 3.1, Ocelot, Identity service using JWT, Docker)
During Lock-down period, after wrapping up my head around Docker, Container, Docker-Compose file, Ocelot, Kubernetes & JWT Token based authentication, It’s time to create full-fledged back-end microservice architecture by combining all . Initially, it was difficult to create such architecture but eventually I accomplished all at once .
The sample application is build based on the Microservices architecture. The above diagram shows the high level design of Back-end architecture.
- Identity Microservice / Provider— Authenticates user based on username, password and issues a JWT Bearer token which contains Claims-based identity information in it.
- API Gateway — Acts as a center point of entry to the back-end application, Provides data aggregation and communication path to microservices.
- Service A & B — These are micro-services for serving different purpose.
Benefits of Microservices:
- Independent scaling
- Independent releases and deployments — Bug fixes and feature releases are more manageable and less risky, with microservices. You can update a service without redeploying the entire application, and roll back or roll forward an update if something goes wrong.
- Independent development — Each service has its own codebase, which is developed, tested, and deployed by a small focused team. Developers can focus on one service and relatively-small scope only. This results in enhanced productivity, project velocity, continuous innovation, and quality at source.
- Graceful degradation — If a service goes down, its impact won’t propagate to the rest of application and result in a catastrophic failure of the system, allowing a certain degree of anti-fragility to manifest.
- Decentralized governance — Developers are free to pick the technology stacks and make design standards and implementation decisions that are best suited for their service. Teams do not have to get penalized due to past technology decisions.
- Docker Desktop (For windows)
- .Net core framework ( we are using VS 2019 )
- Working Docker Image of your microservices in an image repository somewhere. — I’ll be using an image on local machine.
- Ocelot for Middleware gateway.
- Identity service using JWT based Authentication.
Using the Code
Simple Microservice architecture app. Contribute to sksonudas/POC development by creating an account on GitHub.
- ProjectDetailService folder contains sample code of Project details.
- EmployeeService folder contains sample code of getting Employee details.
- Identity folder contains sample code of JWT based authentication.
- APIGateway folder contains sample code of Ocelot based middleware for re-routing.
- ClientApp folder contains sample code of console based client app.
The API Gateway ,Identity, EmployeeService & ProjectDetailService microservices are deployed to our docker’s container so i’ll be using that image in ocelot.jon file for rerouting .
Execute the client app as below :
Hence our job is done !!!
In this article, we have covered what a microservices architecture is, why you’d want to deploy a microservices architecture, and thoughts on getting started. Also, we have looked at how to implement Microservice architecture based simple application.
Has this article been useful to you? please share extensively, we also welcome feedback on content you would like us to cover .