Skip to content

riengcs/spring-cloud-k8s-ecommerce

 
 

Repository files navigation

☁️ Spring Cloud K8s Microservices Platform

🏷️ Tech Stack

☕ Core

Java Spring Boot Spring Cloud

⚙️ Infrastructure & Orchestration

Kubernetes Helm API Gateway

🗄️ Data & Messaging

MySQL Redis RabbitMQ

🛡️ Resilience & Communication

Resilience4j Zipkin

📊 Monitoring & Observability

Prometheus Grafana

A DevOps + microservices project that orchestrates a distributed Spring Boot application in Kubernetes using Helm, monitored with Prometheus & Grafana, with tracing via Zipkin and asynchronous communication via RabbitMQ.

📦 The app simulates an e-commerce ecosystem where customers can order products, orders are automatically processed, and notifications are sent asynchronously through RabbitMQ.


⚙️ Features

  • ✅ Fully automated deployment using Helm
  • 📊 Metrics monitoring (CPU, RAM, etc.) with Prometheus + Grafana
  • 📬 Message distribution via RabbitMQ (order-servicenotification-service)
  • 🔍 Tracing with Zipkin
  • 📂 Configurable persistence (MySQL, Redis)
  • 🔁 Liveness & Readiness probes
  • 📊 Resource Requests, Limits & HPA (when enabled)

🏗 Architecture Highlights

  • API Gateway with Redis rate limiting & Circuit Breakers
  • Resilient Communication with Resilience4j
  • Asynchronous Messaging with Spring Cloud Stream (RabbitMQ / Kafka-ready)
  • Distributed Tracing with Zipkin
  • Metrics Exposure with Spring Boot Actuator
  • Optimized Docker Images following multi-stage build best practices
  • Spring Cloud Bus for real-time propagation of configuration changes

🌐 Microservices Overview

Service Local Access URL Description
gateway-server http://localhost:8080 Routes incoming requests to microservices. Integrated with Redis for rate limiting and Resilience4j for Circuit Breakers. Exposes metrics via Spring Boot Actuator and is connected to Zipkin for distributed tracing.
order-service http://localhost:8082 Calls product-service via Feign to register orders and check stock. Integrated with Resilience4j for resilience. After processing, publishes messages via RabbitMQ to notification-service. Uses Spring Cloud Stream for broker flexibility. Exposes Actuator metrics and sends tracing data to Zipkin.
product-service http://localhost:8081 Stores product information. Exposes Actuator metrics and sends tracing data to Zipkin.
notification-service http://localhost:8083 Saves notifications in the database and logs them. Can be extended with email/SMS. Connected to RabbitMQ via Spring Cloud Stream. Exposes Actuator metrics and sends tracing data to Zipkin.
mysql N/A (internal) Relational database
redis N/A (internal) Used by gateway-server for rate limiting
rabbitmq http://localhost:15672 Message broker: used by order-service to notify notification-service
grafana http://localhost:3000 Metrics dashboard
prometheus http://localhost:9090 Metrics collector
zipkin http://localhost:9411 Distributed request tracing

🐳 Docker Images

Each microservice is built into a Docker image used during Kubernetes deployment.

Microservice Docker Image Role
gateway-server xalx1/gateway-server:2.0.0-k8s Routing + Rate Limiting
order-service xalx1/order-service:2.0.0-k8s Order processing
product-service xalx1/product-service:2.0.0-k8s Product catalog
notification-service xalx1/notification-service:2.0.0-k8s Async notifications

🧰 Requirements

  • Docker
  • Helm
  • Minikube
  • Java 17+
  • Maven / Gradle
  • Kubectl

📁 Project Structure

spring-cloud-k8s/
├── gateway-server/           # API Gateway (Spring Cloud Gateway)
├── notification-service/     # Notification microservice
├── order-service/            # Order management microservice
├── product-service/          # Product catalog microservice
├── k8s-charts/              # Helm charts for each service and infrastructure
├── k8s-manifests/           # K8s manifests (optional)
├── scripts/                  # Automation and helper scripts
└── README.md

🔧 Quick Installation

# 1. Start Minikube
sh scripts/init-minikube.sh

# 2. Deploy all infrastructure and services
sh scripts/deploy-all.sh

# 3. (Optional) Port forward for local UI access
sh scripts/port-forward.sh

📡 Monitoring & Observability

Grafana

Prometheus

Zipkin (Tracing)


📩 Quick API Testing

# Get all products
curl http://localhost:8081/products

# Get all orders
curl http://localhost:8082/orders

# Create new order (triggers async notification)
curl -X POST http://localhost:8082/orders \
  -H "Content-Type: application/json" \
  -d '{"productId": 1, "quantity": 2, "customerEmail": "test@example.com"}'

# Get notifications
curl http://localhost:8083/notifications

🧪 Included Scripts (/scripts)

Script Description
init-minikube.sh Starts Minikube and sets up context
deploy-all.sh Full Helm-based deployment of all services
delete-all.sh Removes all Helm releases from the project
status.sh Shows status of K8s resources
port-forward.sh Exposes local ports for UI access (Grafana, RabbitMQ, etc.)

📌 Notes

  • Config values (resources, persistence, HPA) are adjustable via values.yaml
  • HPA is enabled only when autoscaling.enabled=true in the Helm chart
  • Persistent storage uses auto-generated PersistentVolumeClaim objects
  • The architecture is easily extensible with new services or DevOps tools

📊 Dashboards & UIs

Gateway

Gateway
➡️ http://localhost:8080

Zipkin (Tracing)

Zipkin UI
➡️ http://localhost:9411

Prometheus

Prometheus
➡️ http://localhost:9090

Grafana

Grafana Dashboard
➡️ http://localhost:3000 (login: admin/admin)

About

E-commerce microservices platform with Spring Cloud & Kubernetes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 46.1%
  • Smarty 38.2%
  • Shell 11.7%
  • Dockerfile 4.0%