Files
k8smanager-cli/README.md
T
cnbugs d5d7e45ded feat: K8S智能诊断平台 - 一键诊断+AI分析+Web仪表盘
- 后端: FastAPI + kubectl 9大检查项(Pod/Node/Event/Deploy/Service/PVC/资源/网络)
- AI Agent: OpenAI兼容接口自动分析故障根因+多轮追问对话
- 前端: Vue3 + Element Plus 仪表盘, 健康评分, 问题列表, 资源监控
- 一键启动脚本 start.sh
2026-07-25 10:32:26 +08:00

84 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# K8S 智能诊断平台
一键诊断 Kubernetes 集群健康状态,接入 AI Agent 自动分析故障根因并给出修复建议。
![界面预览](/home/cnbugs/.hermes/cache/screenshots/browser_screenshot_b258ca152c1e489fa186583946ecbd9e.png)
## 功能特性
- **一键诊断**:9 大检查项全面扫描集群状态
- 集群信息、Pod 状态、Node 状态、异常事件
- Deployment 副本检查、Service/Endpoint 检查
- PVC 存储检查、节点资源使用率、网络策略
- **健康评分**:100 分制量化集群健康度(严重问题 -15 分,警告 -5 分)
- **AI 智能分析**:接入 OpenAI 兼容接口,自动分析诊断报告
- 根因定位、影响评估、修复命令、优先级排序、预防建议
- **AI 追问对话**:基于诊断上下文多轮追问,深入排查问题
- **Web 仪表盘**Vue3 + Element Plus,实时展示诊断结果
## 快速开始
```bash
# 1. 确保 kubectl 已配置
kubectl cluster-info
# 2. 启动服务
./start.sh
# 3. 打开浏览器
# http://localhost:8900
```
## 配置
编辑 `.env` 文件:
```env
# AI 分析接口 (OpenAI 兼容格式)
AI_API_BASE=http://localhost:8648/v1
AI_API_KEY=your-api-key
AI_MODEL=qwen3.8-max-preview
# 服务端口
PORT=8900
# Kubeconfig 路径 (留空使用默认 ~/.kube/config)
KUBECONFIG_PATH=
```
## API 接口
| 方法 | 路径 | 说明 |
|------|------|------|
| GET | `/api/health` | 健康检查 |
| GET | `/api/checks` | 列出所有诊断项 |
| POST | `/api/diagnose` | 执行诊断 `{"namespace":"", "checks":[]}` |
| GET | `/api/diagnosis/latest` | 获取最近诊断结果 |
| POST | `/api/analyze` | AI 分析诊断结果 `{"question":""}` |
| POST | `/api/chat` | AI 多轮对话 `{"messages":[...]}` |
| GET | `/api/report` | 获取诊断报告文本 |
## 技术栈
- **后端**Python 3 + FastAPI + kubernetes-client (kubectl)
- **前端**Vue 3 + Element Plus + Vite + marked
- **AI**OpenAI 兼容 Chat Completions API
## 项目结构
```
k8smanager-cli/
├── backend/
│ ├── main.py # FastAPI 主应用
│ ├── config.py # 配置管理
│ ├── diagnosis.py # K8S 诊断引擎 (9 大检查项)
│ └── ai_agent.py # AI Agent 分析模块
├── frontend/
│ ├── src/App.vue # 仪表盘界面
│ ├── index.html
│ └── vite.config.js
├── .env # 配置文件
├── start.sh # 一键启动脚本
└── README.md
```