Microservice Architecture with Spring Cloud, Prometheus, Grafana, and Keycloak using Kubernetes

· by Kuldeep Singh · 2 min read

When I started research on building microservice architecture with completely opensource software, I established the following as key guiding principles:

  • Opensource technology stack, which is proven & battle-tested for production systems
  • Applying API Gateway pattern for Microservices
  • Wider developer community support with active support (in case there are issues or troubleshooting needed)
  • Good documentation with easily accessible learning material

These principles helped me to choose the technology stack, which has been outlined in the next section.

Technology Stack

Technology Usage
Spring Cloud Gateway As API Gateway with support for handing cross-cutting concerns such as security, monitoring/metrics, and resiliency
Spring Boot For microservices development
Grafana For observability with dashboard and visualizing monitoring metrics like system CPU, memory, disk and I/O utilization, etc.
Datasource added for visualization:
Prometheus, Jaeger, Loki
Prometheus For capturing data metrics & alerts with time-series data
Keycloak For identity and access management (opensource)
Jaeger For end-to-end distributed tracing
Resilience4j For fault-tolerance management (similar to Netflix Hystrix but lightweight)
Loki For Logs Management built at Grafana Lab.
Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheuss.
Kubernetes For container orchestration, deployment, scaling and container management

This led me to create a simple microservices oriented application implementing the following use-cases:

  • 3 or more microservices as per business domain (applying domain-driven design – didn’t name microservices to keep it open)
  • Authenticated application secured with Login flow (with token generation & validation)
  • Service routing to the intended microservice
  • Managing non-functional aspects such as caching, monitoring, distributed tracing, logging, etc.

Architecture Flow

Figure A - Microservices Architecture Flow

Figure A – Microservices Architecture Flow

Deployed Stack

  • Deployment steps followed in detail available by clicking here.
  • Kubernetes YAML configuration files are available by clicking here.
  • Microservices are referred as: ms-1, ms-2, ms-3

Figure B - PODs Deployed to Kubernetes

Figure B – PODs Deployed to Kubernetes

Working Code

To conclude, it was an interesting journey with a great learning curve putting these technologies together to build a completely opensource based microservices architecture. Feel free to share your comments.

Comments

online training ·

thank you