refactor: 统一 DB/Redis 配置为 DSN 模式 + 移除 Helm/K8s 部署

- DatabaseConfig: Host/Port/User/Password/Name/DBName/SSLMode → 单个 DSN 字段
- RedisConfig: Host/Port/Password/DB/URL → 单个 DSN 字段
- 环境变量: GOCHAT_DATABASE_* (7个) → GOCHAT_DATABASE_DSN, GOCHAT_REDIS_* (5个) → GOCHAT_REDIS_DSN
- validator.go: DSN URL 解析校验 (scheme + host)
- redis.go: redis.ParseURL(cfg.DSN) 直连
- 所有 docker-compose / CI / shell 脚本 / .env 同步更新
- 删除 deploy/helm/ 整个目录 (20个文件)
- CI 删除 helm-validate / deploy-staging / deploy-production 三个 job
- 文档同步更新 (README, 架构设计, PRD, 滚动升级)
This commit is contained in:
Rogee
2026-07-29 20:58:10 +08:00
parent 851ca7e372
commit 92f0d51375
46 changed files with 185 additions and 1464 deletions
+3 -19
View File
@@ -39,33 +39,17 @@ curl -f http://gochat-green:3000/health
docker compose -f docker-compose.prod.yml stop gochat
```
### Step 4: K8s Rolling Update
```bash
# Kubernetes handles rolling updates automatically via Deployment strategy
kubectl set image deployment/gochat gochat=gochat/gochat:${NEW_VERSION}
kubectl rollout status deployment/gochat
```
K8s config (in Helm chart):
- maxSurge: 1 (one extra pod during rollout)
- maxUnavailable: 0 (no pods allowed to be unavailable)
- readinessProbe: /ready endpoint
- livenessProbe: /live endpoint
### Step 5: Verification
1. Smoke test: hit /health, /ready endpoints
### Step 4: Verification
1. Smoke test: hit /health endpoint
2. Check logs for errors: `docker compose logs gochat --since 5m`
3. Verify metrics: Prometheus dashboard should show normal traffic
4. Monitor for 15 minutes before finalizing
### Step 6: Rollback (if needed)
### Step 5: Rollback (if needed)
```bash
# Docker Compose rollback
docker compose -f docker-compose.prod.yml exec gochat /app/gochat migrate down ${N}
docker compose -f docker-compose.prod.yml up -d --no-deps gochat-${OLD_VERSION}
# K8s rollback
kubectl rollout undo deployment/gochat
```
## Migration Compatibility Rules
+2 -2
View File
@@ -352,7 +352,7 @@ GoChat 是一个开源的企业级多渠道客服平台,旨在为企业提供
| Prometheus 指标导出 | ❌ | 2天 |
| Grafana Dashboard 模板 | ❌ | 1天 |
| OpenTelemetry 分布式追踪 | ❌ | 3天 |
| Kubernetes Helm Chart | ❌ | 3天 |
| Kubernetes Helm Chart | ❌ | 已移除 |
| JSON 结构化日志 | ⚠️ zap有 | 1天 |
| 健康检查增强 | ⚠️ | 1天 |
| SLA 管理 | ❌ stub | 3天 |
@@ -427,7 +427,7 @@ GoChat 是一个开源的企业级多渠道客服平台,旨在为企业提供
**验收标准**:
1. Prometheus/Grafana 监控面板可用
2. OpenTelemetry 追踪可用
3. Kubernetes Helm Chart 可一键部署
3. Docker Compose 一键部署可用
4. SLA 管理/审计日志可用
5. Slack/API Channel 渠道可用
6. CI/CD 完整流水线运行
+4 -9
View File
@@ -311,8 +311,9 @@ gochat/
│ + 对应 down.sql 回滚文件
│
├── deploy/ # 部署配置
│ ├── k8s/ # Kubernetes manifests
│ ├── docker/ # Docker 相关
│ ├── docker/ # Dockerfile + docker-compose
│ ├── quickstart/ # 一键启动 Compose 栈
│ ├── fluentd/ # 日志收集
│
├── tests/ # 测试目录
│ ├── e2e/ # 端到端测试
@@ -1162,13 +1163,7 @@ docker-compose.prod.yml → 生产 (健康检查 + 资源限制)
docker-compose.test.yml → 测试 (独立PG + 覆盖率)
```
### 12.2 Kubernetes 部署
```
deploy/k8s/ → Deployment + Service + ConfigMap + Secret manifests
```
### 12.3 环境配置优先级
### 12.2 环境配置优先级
```
.env (最高) → configs/production.yaml → configs/default.yaml → 程序默认值
+1 -1
View File
@@ -473,7 +473,7 @@ gochat/
│ ├── docker/
│ │ ├── Dockerfile
│ │ └── docker-compose.yaml
│ └── k8s/ # Kubernetes配置(可选)
│ └── quickstart/ # 一键启动 Compose 栈
│
├── go.mod # Go模块定义
├── go.sum # Go依赖锁定