72 lines
2.1 KiB
Markdown
72 lines
2.1 KiB
Markdown
# 阶段 2 计划:K8s 健康检查委托
|
||
|
||
## 目标
|
||
|
||
将 K8s 服务健康监控从网关移除,委托给 fengling-console。网关只专注于请求路由。
|
||
|
||
## 需要移除的代码
|
||
|
||
### 1. 后台服务
|
||
- **文件**: `src/yarpgateway/Services/KubernetesPendingSyncService.cs`
|
||
- **操作**: 删除文件
|
||
- **影响**: 停止每 30 秒同步 K8s 服务
|
||
|
||
### 2. 服务注册
|
||
- **文件**: `src/yarpgateway/Program.cs`
|
||
- **行号**: ~118
|
||
- **代码**: `builder.Services.AddHostedService<KubernetesPendingSyncService>();`
|
||
- **操作**: 删除该行
|
||
|
||
### 3. API 控制器
|
||
- **文件**: `src/yarpgateway/Controllers/PendingServicesController.cs`
|
||
- **操作**: 删除文件
|
||
- **影响**: 移除 `/api/gateway/pending-services/*` API
|
||
|
||
### 4. 数据模型
|
||
- **文件**: `src/yarpgateway/Models/GwPendingServiceDiscovery.cs`
|
||
- **操作**: 删除文件
|
||
- **影响**: 移除待处理服务发现实体
|
||
|
||
### 5. DbContext
|
||
- **文件**: `src/yarpgateway/Data/GatewayDbContext.cs`
|
||
- **操作**: 移除 `DbSet<GwPendingServiceDiscovery>` 属性
|
||
|
||
### 6. 迁移文件(可选)
|
||
- **文件**: `src/yarpgateway/Migrations/20260222134342_AddPendingServiceDiscovery.cs`
|
||
- **操作**: 保留(数据库已有该表)或删除(如果重新创建数据库)
|
||
|
||
## 不需要移除
|
||
|
||
| 组件 | 理由 |
|
||
|------|------|
|
||
| DatabaseClusterConfigProvider | YARP 集群配置仍然需要 |
|
||
| PgSqlConfigChangeListener | 配置监听仍然需要 |
|
||
| 现有健康检查 | YARP 内置被动健康检查 |
|
||
|
||
## 实现顺序
|
||
|
||
1. 移除 PendingServicesController.cs
|
||
2. 移除 KubernetesPendingSyncService.cs
|
||
3. 移除 GwPendingServiceDiscovery.cs
|
||
4. 更新 GatewayDbContext.cs
|
||
5. 更新 Program.cs
|
||
6. 更新 ROADMAP.md 标记为完成
|
||
7. 提交代码
|
||
|
||
## 风险
|
||
|
||
- **数据丢失**: 如果数据库已有 `PendingServiceDiscoveries` 表,删除代码后数据仍然存在但无法访问
|
||
- **API 变更**: 移除 `/api/gateway/pending-services/*` 端点,需要通知 console 团队
|
||
|
||
## 验证
|
||
|
||
完成后验证:
|
||
- `dotnet build` 成功
|
||
- 无 `KubernetesPendingSyncService` 引用
|
||
- 无 `PendingServicesController` 引用
|
||
- 无 `GwPendingServiceDiscovery` 引用
|
||
|
||
---
|
||
|
||
*计划创建: 2026-03-02*
|