|
|
2 tháng trước cách đây | |
|---|---|---|
| charts | 2 tháng trước cách đây | |
| environments | 3 tháng trước cách đây | |
| scripts | 2 tháng trước cách đây | |
| templates | 3 tháng trước cách đây | |
| Chart.yaml | 3 tháng trước cách đây | |
| DEPLOYMENT_CLEANUP_GUIDE.md | 2 tháng trước cách đây | |
| Dockerfile-optimization-guide.md | 3 tháng trước cách đây | |
| Dockerfile.optimized | 3 tháng trước cách đây | |
| GLOBAL_VALUES_REFACTORING.md | 2 tháng trước cách đây | |
| README.md | 2 tháng trước cách đây | |
| values.yaml | 2 tháng trước cách đây |
这是一个企业级微服务平台的Helm Chart实现,采用Umbrella Chart + 通用模板库的混合架构。用于管理Shop Recycle项目的34个Java Spring Cloud微服务的统一部署、配置管理和多环境部署。
架构版本: 1.0.0
项目名称: Shop Recycle
微服务数量: 34个
部署环境: dev, staging, production
Spring Cloud框架: Spring Cloud Nacos + Dubbo
端口范围: 1201-1239
✅ Umbrella Chart架构 - 统一部署管理34个微服务
✅ 模板代码复用 - 通用base chart,消除重复代码
✅ 灵活的服务启用/禁用 - 可按需启用或禁用任意微服务
✅ 多环境配置管理 - 开发、测试、生产环境差异化配置
✅ 全局配置共享 - 支持跨服务的全局配置
✅ Spring Cloud原生支持 - Nacos服务注册、Dubbo通信
✅ 生产就绪 - 包含health check、资源限制、副本控制
microservice-helm/
├── Chart.yaml # Umbrella Chart定义(34个依赖)
├── values.yaml # 全局配置(各服务默认值)
├── README.md # 本文档
├── templates/ # 根级templates(通常为空)
│ ├── configmap.yaml
│ ├── deployment.yaml
│ └── service.yaml
├── charts/ # 子Chart目录(34个微服务+base)
│ ├── base/ # 🔷 通用模板库
│ │ ├── Chart.yaml
│ │ ├── values.yaml
│ │ └── templates/
│ │ ├── configmap.yaml # 标准化的Spring Cloud应用属性
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ │
│ ├── 核心业务服务 (9个)
│ │ ├── shop-recycle-payment/ # 支付服务 (1218)
│ │ ├── shop-recycle-store/ # 商店服务 (1208)
│ │ ├── shop-recycle-pis/ # PIS服务 (1209)
│ │ ├── shop-recycle-merchant/ # 商家服务 (1204)
│ │ ├── shop-recycle-account/ # 账户服务 (1223)
│ │ ├── shop-recycle-msg/ # 消息服务 (1217)
│ │ ├── shop-recycle-order-center/ # 订单中心 (1203)
│ │ ├── shop-recycle-wechat/ # 微信服务 (1231)
│ │ └── shop-recycle-order-search/ # 订单查询 (1238)
│ │
│ ├── 数据和基础服务 (8个)
│ │ ├── shop-recycle-data-statistics/ # 数据统计 (1220)
│ │ ├── shop-recycle-platform/ # 平台服务 (1201)
│ │ ├── shop-recycle-sche/ # 调度服务 (1215)
│ │ ├── shop-recycle-dispatcher/ # 分发器 (1236)
│ │ ├── shop-recycle-dealdata-service/ # 数据处理服务 (1235)
│ │ ├── shop-recycle-async-web/ # 异步服务 (1239)
│ │ └── shop-recycle-import-web/ # 导入Web (1221)
│ │
│ ├── 网关拓展服务 (4个)
│ │ ├── shop-recycle-gateway-out/ # 外部网关 (1226)
│ │ ├── shop-recycle-gateway-out-upgrade/# 网关升级 (1237)
│ │ ├── shop-recycle-out-web/ # 外部Web (1224)
│ │ └── shop-recycle-gateway/ # API网关 (1211)
│ │
│ ├── 客户端Web服务 (8个)
│ │ ├── shop-recycle-wechat-web/ # 微信Web (1214)
│ │ ├── shop-recycle-payment-web/ # 支付Web (1219)
│ │ ├── shop-recycle-store-wechat-web/ # 店铺微信Web (1207)
│ │ ├── shop-recycle-customer-wechat-web/# 客户微信Web (1227)
│ │ ├── shop-recycle-merchant-wechat-web/# 商家微信Web (1206)
│ │ ├── shop-recycle-oss-web/ # OSS Web (1212)
│ │ ├── shop-recycle-login-center/ # 登录中心 (1210)
│ │ └── shop-recycle-vs-web/ # VS Web (1233)
│ │
│ └── 管理后台服务 (6个)
│ ├── shop-recycle-platform-pc-web/ # 平台PC Web (1202)
│ ├── shop-recycle-store-pc-web/ # 店铺PC Web (1222)
│ ├── shop-recycle-marketer-pc-web/ # 营销PC Web (1232)
│ ├── shop-recycle-erp-pc-web/ # ERP PC Web (1228)
│ ├── shop-recycle-merchant-pc-web/ # 商家PC Web (1205)
│ └── shop-recycle-agent-pc-web/ # 代理PC Web (1225)
│
└── environments/ # 环境特定配置
├── dev-values.yaml # 开发环境(DEBUG日志、单副本)
├── staging-values.yaml # 预发布环境(INFO日志、双副本)
└── prod-values.yaml # 生产环境(WARN日志、三副本、高资源)
helm install shop-recycle ./
# 开发环境
helm install shop-recycle ./ \
-f environments/dev-values.yaml
# 预发布环境
helm install shop-recycle ./ \
-f environments/staging-values.yaml
# 生产环境
helm install shop-recycle ./ \
-f environments/prod-values.yaml
# 仅部署核心后端服务
helm install shop-recycle ./ \
--set shop-recycle-payment.enabled=true \
--set shop-recycle-store.enabled=true \
--set shop-recycle-merchant.enabled=true \
--set shop-recycle-gateway.enabled=true
# 禁用特定Web服务
helm install shop-recycle ./ \
--set shop-recycle-marketer-pc-web.enabled=false \
--set shop-recycle-erp-pc-web.enabled=false
helm install shop-recycle ./ \
--set global.image.registry=your-registry \
--set shop-recycle-payment.image.tag=v2.0.0
# 查看Release状态
helm status shop-recycle
# 查看所有部署的资源
kubectl get all -l platform=microservice-platform
# 查看所有Pod
kubectl get pods -l project=shop-recycle
# 查看Service和端口
kubectl get svc
| 服务名称 | 端口 | 说明 |
|---|---|---|
| shop-recycle-payment | 1218 | 支付服务 |
| shop-recycle-store | 1208 | 商店服务 |
| shop-recycle-pis | 1209 | PIS系统 |
| shop-recycle-merchant | 1204 | 商家管理 |
| shop-recycle-account | 1223 | 账户管理 |
| shop-recycle-msg | 1217 | 消息服务 |
| shop-recycle-order-center | 1203 | 订单中心 |
| shop-recycle-wechat | 1231 | 微信集成 |
| shop-recycle-order-search | 1238 | 订单查询 |
| 服务名称 | 端口 | 说明 |
|---|---|---|
| shop-recycle-platform | 1201 | 平台核心 |
| shop-recycle-data-statistics | 1220 | 数据统计 |
| shop-recycle-sche | 1215 | 调度服务 |
| shop-recycle-dispatcher | 1236 | 分发服务 |
| shop-recycle-dealdata-service | 1235 | 数据处理 |
| shop-recycle-async-web | 1239 | 异步处理 |
| shop-recycle-import-web | 1221 | 数据导入 |
| 服务名称 | 端口 | 说明 |
|---|---|---|
| shop-recycle-gateway-out | 1226 | 外部网关 |
| shop-recycle-gateway-out-upgrade | 1237 | 网关升级 |
| shop-recycle-out-web | 1224 | 外部Web |
| shop-recycle-gateway | 1211 | API网关 |
| 服务名称 | 端口 | 说明 |
|---|---|---|
| shop-recycle-wechat-web | 1214 | 微信Web |
| shop-recycle-payment-web | 1219 | 支付Web |
| shop-recycle-store-wechat-web | 1207 | 店铺微信Web |
| shop-recycle-customer-wechat-web | 1227 | 客户微信Web |
| shop-recycle-merchant-wechat-web | 1206 | 商家微信Web |
| shop-recycle-oss-web | 1212 | 文件管理 |
| shop-recycle-login-center | 1210 | 登录中心 |
| shop-recycle-vs-web | 1233 | VS页面 |
| 服务名称 | 端口 | 说明 |
|---|---|---|
| shop-recycle-platform-pc-web | 1202 | 平台PC Web |
| shop-recycle-store-pc-web | 1222 | 店铺PC Web |
| shop-recycle-marketer-pc-web | 1232 | 营销管理 |
| shop-recycle-erp-pc-web | 1228 | ERP系统 |
| shop-recycle-merchant-pc-web | 1205 | 商家后台 |
| shop-recycle-agent-pc-web | 1225 | 代理后台 |
global:
labels:
environment: development
shop-recycle-payment:
enabled: true
app:
replicaCount: 1
image:
tag: dev-latest
config:
yml:
logging:
level:
root: DEBUG
global:
labels:
environment: staging
shop-recycle-payment:
enabled: true
app:
replicaCount: 2
image:
tag: staging-latest
global:
labels:
environment: production
shop-recycle-payment:
enabled: true
app:
replicaCount: 3
image:
tag: "1.0.0"
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 1000m
memory: 1024Mi
helm install shop-recycle ./
#!/bin/bash
# 开发环境
helm install shop-recycle-dev ./ \
--namespace dev \
--create-namespace \
-f environments/dev-values.yaml
# 预发布环境
helm install shop-recycle-staging ./ \
--namespace staging \
--create-namespace \
-f environments/staging-values.yaml
# 生产环境
helm install shop-recycle-prod ./ \
--namespace prod \
--create-namespace \
-f environments/prod-values.yaml
helm upgrade shop-recycle ./ \
--set shop-recycle-payment.image.tag=v2.0.0 \
--set shop-recycle-store.image.tag=v2.0.0
# 查看所有Pod
kubectl get pods -l project=shop-recycle -o wide
# 查看特定服务日志
kubectl logs -l app=shop-recycle-payment -f
# 验证服务健康
curl -s localhost:1218/actuator/health | jq .
# 验证Chart语法
helm lint ./
# 渲染模板
helm template shop-recycle ./
# 查看特定环境的配置
helm template shop-recycle ./ -f environments/prod-values.yaml
# 转发payment服务
kubectl port-forward svc/shop-recycle-payment 1218:1218
# 转发gateway服务
kubectl port-forward svc/shop-recycle-gateway 1211:1211
# 测试
curl http://localhost:1218/actuator/health
# 查看所有服务日志
kubectl logs -l project=shop-recycle -f
# 查看特定服务日志
kubectl logs -l app=shop-recycle-payment -f
# 查看最近的日志
kubectl logs -l app=shop-recycle-payment --tail=50
helm uninstall shop-recycle
Umbrella Chart 管理34个子Chart,提供:
所有微服务的配置文件已集成到对应的charts/<service-name>/values.yaml中的config.yml部分,包含以下标准配置:
kubectl autoscale deployment shop-recycle-payment \
--min=2 --max=10 --cpu-percent=80
详见各环境配置文件。
kubectl create secret generic db-credentials \
--from-literal=username=dbuser \
--from-literal=password=dbpass
所有服务都配置了liveness和readiness probe,使用/actuator/health端点。
Q: 如何修改服务端口?
A: 各服务的端口号已在对应的charts/<service-name>/values.yaml中的service.port和service.targetPort字段中定义。
Q: 是否可以修改应用名称?
A: 应用名称固定为service name,在configmap模板中自动设置。
Q: 如何只部署部分服务?
A: 使用--set <service-name>.enabled=false禁用不需要的服务。
最后更新: 2026-01-15
维护者: DevOps Team
项目: Shop Recycle Microservice Platform