Microservices with Spring Cloud

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

TechnologyUsage
Spring Cloud GatewayAs API Gateway with support for handing cross-cutting concerns such as security, monitoring/metrics, and resiliency
Spring BootFor microservices development
GrafanaFor observability with dashboard and visualizing monitoring metrics like system CPU, memory, disk and I/O utilization, etc.
Datasource added for visualization:
Prometheus, Jaeger, Loki
PrometheusFor capturing data metrics & alerts with time-series data
KeycloakFor identity and access management (opensource)
JaegerFor end-to-end distributed tracing

Resilience4j
For fault-tolerance management (similar to Netflix Hystrix but lightweight)
LokiFor Logs Management built at Grafana Lab.
Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheuss.
KubernetesFor 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.

One Thought to “Microservice Architecture with Spring Cloud, Prometheus, Grafana, and Keycloak using Kubernetes”

  1. online training

    thank you

Leave a Comment