feat(k8s): M13 多集群资源对比看板 — GetMultiClusterComparison handler + ClusterComparePage (柱状图/雷达图/饼图/详细对比表)

This commit is contained in:
attacker committed 2026-06-24 05:03:47 +08:00
1 parent 7192f58b72
commit 3d7932c087
9 files changed
+591 -2

No files matched your search

+45
View File
@@ -433,3 +433,48 @@ cd frontend && npx tsc --noEmit && npm run build 2>&1 | tail -3
- [x] 前端三维度柱状图正确渲染(recharts)
- [x] 图表点击联动过滤事件列表
- [x] 最新告警面板展示 Warning 事件
---
## M13: 多集群资源对比看板
### 验证用例
```bash
# U1: 登录获取 Token
TOKEN=$(python3 -c "
import urllib.request, json
login_data = json.dumps({'username': 'admin', 'password': 'admin123'}).encode()
req = urllib.request.Request('http://127.0.0.1:8080/api/v1/auth/login', data=login_data, method='POST')
req.add_header('Content-Type', 'application/json')
resp = urllib.request.urlopen(req)
print(json.loads(resp.read())['data']['token'])
")
# U2: 多集群对比 API
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/compare" \
-H "Authorization: Bearer $TOKEN" | jq '.data | {totals, cluster_count: (.clusters|length)}'
# 期望: totals 含 cluster_count/node_count/pod_count/deployment_count/service_count
# U3: 验证每个集群包含完整字段
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/compare" \
-H "Authorization: Bearer $TOKEN" | jq '.data.clusters[0] | keys'
# 期望: 19 个字段 (id/name/code/status/node_count/pod_count/.../total_cpu_cores/total_memory_mb/master_count/worker_count)
# U4: SPA 路由
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8080/kubernetes/compare
# 期望: 200
# U5: TypeScript + Vite 构建
cd frontend && npx tsc --noEmit && npm run build 2>&1 | tail -3
# 期望: 零错误 + built in Ns
```
### 通过标准
- [x] U2: Compare API 返回 clusters 数组 + totals 聚合数据
- [x] U3: 每个集群包含 19 个字段(含 node 级别聚合数据)
- [x] U4: SPA 路由返回 200
- [x] U5: TypeScript 零编译错误 + Vite 构建成功
- [x] 前端 4 类图表正确渲染(柱状图×2 + 雷达图 + 饼图)
- [x] 详细对比表格可点击跳转集群概览
- [x] totals 聚合正确(cluster_count/node_count/pod_count/deployment_count/service_count)