cover

Overview

17 個 Kubernetes 服務組成的微服務架構,涵蓋 API Gateway、服務間通訊、分散式監控、訊息佇列、快取、資料庫。完整實作從開發到部署的全流程。

Architecture

Client Request
    → Kong API Gateway (路由/限流/認證)
        → Auth Service (FastAPI, JWT/OAuth)
        → Post Service (FastAPI, CRUD/搜索)
        → User Service (FastAPI, 會員管理)
        → ... (其他業務服務)
            → PostgreSQL (持久化)
            → Redis (快取/Session)
            → RabbitMQ (非同步訊息)

Observability Stack:
    Prometheus → Grafana (Metrics 儀表板)
    Fluent-bit → Loki (Log 聚合)
    Tempo (Distributed Tracing)

Services (17)

CategoryServiceDescription
GatewayKongAPI 路由、Rate Limiting、JWT 驗證、Plugin 擴充
業務Auth ServiceJWT 發行/驗證、OAuth 整合、Token Refresh
業務Post Service文章 CRUD、全文搜索、分類標籤
業務User Service會員管理、Profile、權限
資料PostgreSQL主資料庫,每服務獨立 Schema
資料Redis分散式快取、Session Store、Rate Limit Counter
訊息RabbitMQ服務間非同步通訊、Event-Driven 架構
監控PrometheusMetrics 採集、Alert Rules
監控Grafana視覺化儀表板、多資料源整合
監控LokiLog 聚合查詢
監控Tempo分散式追蹤
監控Fluent-bitLog 收集轉發

Key Features

FeatureDescription
Service MeshKong 統一入口,服務間透過內部 DNS 通訊
分散式監控Metrics + Logs + Tracing 三大支柱完整覆蓋
Event-DrivenRabbitMQ 解耦服務,支援 Pub/Sub 與 Work Queue
K8s 原生Deployment / Service / ConfigMap / Secret / HPA 完整配置
Health Check每服務提供 /health endpoint,K8s Liveness/Readiness Probe
環境隔離dev / staging / production 三套環境,Namespace 隔離

架構說明

  • API Gateway (Kong):所有外部請求經過 Kong 統一路由,支援 JWT 驗證 Plugin、Rate Limiting、Request/Response Transform
  • 服務通訊:同步請求走 HTTP/gRPC,非同步事件走 RabbitMQ,避免服務間強耦合
  • 資料隔離:每個微服務擁有獨立的 PostgreSQL Schema,禁止跨服務直接查詢資料庫
  • 監控告警:Prometheus 採集所有服務 Metrics,Grafana 設定 Dashboard + Alert,Loki 集中日誌查詢
  • 分散式追蹤:Tempo 收集跨服務 Trace,可視化請求在各服務間的流轉路徑與延遲

Tech Stack

FastAPI + Uvicorn ・ Kong API Gateway ・ PostgreSQL + Redis + RabbitMQ ・ Prometheus + Grafana + Loki + Tempo + Fluent-bit ・ Docker + Kubernetes ・ Helm Charts


← Back to Portfolio