feat(k8s): M10 Node 详情页 — PID/容器运行时/分配率

- 后端: GetNodeDetail handler — 获取单个节点完整信息
  * 系统信息: container_runtime/architecture/kubelet/os/kernel
  * 资源分配率: 遍历 Pod 计算 CPU/Memory/Pods requested vs allocatable
  * metrics-server 数据注入 (cpu_usage_m/mem_usage_mi)
  * 全量 conditions/taints/labels + 节点上的 Pod 列表
- 后端: K8s 客户端扩展
  * NodeTaint/NodeCondition 扩展字段 (reason/message)
  * NodeInfo 增加 architecture/operatingSystem
  * GetNode(name) 单节点查询方法
  * parseCpuToMilli()/parseMemToMi() 资源解析辅助函数
- 后端: 注册路由
  * GET /kubernetes/:clusterCode/nodes/:name (Kuboard code)
  * GET /kubernetes-clusters/:id/nodes/:name (ID)
- 前端: NodeDetailPage.tsx (~330行)
  * 系统信息卡片 + 资源分配率卡片(进度条)
  * 条件卡片 + 污点卡片 + 标签卡片 + Pod 列表
- 前端: 节点名称可点击跳转 (ClusterOverviewPage)
- 验证: API/SPA/TS/Vite 全部通过
This commit is contained in:
attacker committed 2026-06-23 17:57:09 +08:00
1 parent 28dfc519e1
commit 87b7755094
16 files changed
+921 -52

No files matched your search

+46
View File
@@ -270,6 +270,52 @@ curl -s http://127.0.0.1/ | grep -oP 'index-[A-Za-z0-9]+\.js'
---
## M10: Node 详情页(PID/容器运行时/分配率)
### 验证用例
```bash
# U1: 登录获取 Token
TOKEN=$(curl -s http://127.0.0.1:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}' | jq -r '.data.token')
# U2: Node detail API — Kuboard code route
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/test-k8s/nodes/k8s-master-01" \
-H "Authorization: Bearer *** | jq '.data.container_runtime'
# 期望: "containerd://2.1.4"
# U3: 资源分配率字段
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/test-k8s/nodes/k8s-master-01" \
-H "Authorization: Bearer *** | jq '.data | {cpu_alloc_pct, mem_alloc_pct, pod_alloc_pct, pod_count}'
# 期望: cpu_alloc_pct/mem_alloc_pct/pod_alloc_pct 均为数字 > 0
# U4: conditions + taints + pods 列表
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/test-k8s/nodes/k8s-master-01" \
-H "Authorization: Bearer *** | jq '.data | {conditions: (.conditions|length), taints: (.taints|length), pods: (.pods|length)}'
# 期望: conditions>=4, pods>=1
# U5: SPA fallback — node detail 路由 200
curl -s -o /dev/null -w "%{http_code}" \
"http://127.0.0.1/kubernetes/test-k8s/nodes/k8s-master-01"
# 期望: 200
# U6: TypeScript + Vite 构建
cd frontend && npx tsc --noEmit && npm run build 2>&1 | tail -3
# 期望: 零错误 + built in Ns
```
### 通过标准
- [x] U1: 登录成功
- [x] U2: Node detail API 返回 container_runtime/kubelet/os/kernel/architecture
- [x] U3: 资源分配率正确(cpu_alloc_pct/mem_alloc_pct/pod_alloc_pct 数字)
- [x] U4: conditions/taints/pods 列表非空
- [x] U5: SPA 路由 200(非 301)
- [x] U6: TypeScript 零错误 + Vite 构建成功
- [x] 前端节点名称可点击跳转详情页
---
## M9: 服务/应用路由 Tab + 整体联调
### 验证用例