fix: scale replicas in response, K8s metrics client, quota precheck, auth tests
- Add GetMetrics method to MetricsClient interface and implement cluster metrics API - Add QuotaPrecheck service for validating resource quotas before deployment - Add auth DTO with role/permission models and auth handler tests - Add instance diagnostics: mounted NFS volumes, labels, annotations in pod diagnostics - Update workspace handler with GetWorkspace endpoint and shared-user list - Fix monitoring handler to use correct service method name - Add tail_lines fallback in instance handler for snake_case query params - Update nginx config for SSE log streaming support (no buffering) - Add comprehensive test coverage: auth_service_test, auth_handler_test, auth_dto_test, metrics_client_test, quota_precheck_test - Update error messages for quota validation and instance operations - ModifyModal: fix YAML lineWidth:0, modified keys summary, delta-only submit - InstanceCard: correctly disable scale-minus when replicas <= 0 - SidebarLayout: add hover transition for sidebar items - Update todo.md and lessons.md with latest fixes
This commit is contained in:
72
README.md
72
README.md
@ -1,4 +1,4 @@
|
||||
# OCDP - Open Cloud Deployment Platform
|
||||
# OCDP - One Click Deployment Platform
|
||||
|
||||
OCDP 是一个面向 Kubernetes 的大模型推理部署平台。当前核心场景是:用户在页面选择 Harbor 中的 `vllm-serve` Helm Chart,填写实例名称、命名空间和 values 后,后端从 Harbor 拉取封装好的 OCI Helm Chart,并通过 Helm SDK 部署到已配置好的 Kubernetes 集群。
|
||||
|
||||
@ -29,9 +29,9 @@ ocdp-go/
|
||||
│ └── internal/bootstrap/ # 首次启动数据注入
|
||||
├── frontend/ # React + Vite 前端
|
||||
├── infra/nginx/ # Nginx 网关配置和 TLS 证书
|
||||
├── docker-compose.yml # 本地完整部署:PostgreSQL + Backend + 前端 build + Nginx
|
||||
├── docker-compose.yml # 本地完整部署入口:PostgreSQL + Backend + 前端 build job + Nginx
|
||||
├── backend/docker-compose.yml # PostgreSQL + Backend + pgAdmin
|
||||
├── Makefile # 推荐入口:install / run-2 / docker-dev / docker-down
|
||||
├── Makefile # 推荐入口:up / restart / stop / logs / ps
|
||||
└── tasks/ # Agent 工作记录
|
||||
```
|
||||
|
||||
@ -119,29 +119,29 @@ GOSUMDB=sum.golang.google.cn
|
||||
|
||||
## 推荐部署流程
|
||||
|
||||
当前推荐使用根目录 Makefile。`docker-dev`、`docker-prod`、`docker-up` 都是兼容旧文档的别名,实际会启动同一套完整 Docker Compose 栈:PostgreSQL、Backend、前端静态构建和 Nginx。
|
||||
当前只有一个推荐启动入口:在项目根目录执行 `make up`。它会启动同一套完整 Docker Compose 栈:
|
||||
|
||||
- `postgres`:数据库,常驻服务。
|
||||
- `backend`:Go API,常驻服务,宿主机默认端口 `18081`。
|
||||
- `frontend-build`:一次性构建任务,构建完成后退出是正常现象。
|
||||
- `nginx`:统一 Web 入口,常驻服务,宿主机默认端口 `18080`;前端静态文件和 `/api/*` 都从这里访问。
|
||||
|
||||
所以看到 `frontend-build` 处于 `Exited (0)` 不代表前端没运行;前端由 `nginx` 服务。正常运行时至少应看到 `postgres`、`backend`、`nginx` 三个容器为 `Up`。
|
||||
|
||||
```bash
|
||||
# 1. 在根目录检查 .env
|
||||
ls .env
|
||||
|
||||
# 2. 可选:安装本地依赖。只部署 Docker 栈时不是必须,但这个命令可用。
|
||||
make install
|
||||
|
||||
# 3. 如果默认高位端口仍被其他项目占用,再临时换端口
|
||||
# 2. 如果默认高位端口被其他项目占用,先换端口;不要杀其他项目进程
|
||||
export WEB_HTTP_PORT=18080
|
||||
export WEB_HTTPS_PORT=18443
|
||||
export BACKEND_PORT=18081
|
||||
export POSTGRES_PORT=15432
|
||||
|
||||
# 4. 构建并后台启动完整栈
|
||||
make run-2
|
||||
# 3. 构建并后台启动完整平台
|
||||
make up
|
||||
|
||||
# 兼容旧文档,也可以执行:
|
||||
make docker-dev
|
||||
make docker-prod
|
||||
|
||||
# 5. 查看服务
|
||||
# 4. 查看服务;postgres/backend/nginx 应为 Up,frontend-build Exited(0) 正常
|
||||
make docker-ps
|
||||
```
|
||||
|
||||
@ -152,14 +152,23 @@ make docker-ps
|
||||
- Swagger UI:http://localhost:${BACKEND_PORT:-18081}/api/docs
|
||||
- Nginx 健康检查:http://localhost:${WEB_HTTP_PORT:-18080}/healthz
|
||||
|
||||
没有 Make 时,直接用根目录 Compose 文件即可。注意要加 `--build`,因为后端镜像和前端静态资源需要构建:
|
||||
兼容旧文档的命令仍可用,但只是 `make up` 的别名:
|
||||
|
||||
```bash
|
||||
docker compose up --build -d postgres backend nginx
|
||||
docker compose ps
|
||||
make run-2
|
||||
make docker-dev
|
||||
make docker-prod
|
||||
make docker-up
|
||||
```
|
||||
|
||||
如果直接执行 `docker compose up`,Compose 也会使用同一个完整栈;但在代码或 Dockerfile 改动后建议显式加 `--build`,避免复用旧镜像。
|
||||
没有 Make 时,直接用根目录 Compose 文件:
|
||||
|
||||
```bash
|
||||
docker compose up --build -d
|
||||
docker compose ps -a
|
||||
```
|
||||
|
||||
代码、Dockerfile、前端资源变更后都建议使用 `make up` 或 `docker compose up --build -d`,避免复用旧镜像或旧前端静态资源。
|
||||
|
||||
## 验证部署
|
||||
|
||||
@ -210,20 +219,30 @@ ADMIN_PASS="<BOOTSTRAP_ADMIN_PASS>" \
|
||||
## 常用运维命令
|
||||
|
||||
```bash
|
||||
# 一条命令启动/更新完整平台
|
||||
make up
|
||||
|
||||
# 强制重建并重启完整平台
|
||||
make restart
|
||||
|
||||
# 查看当前状态;需要关注 postgres/backend/nginx 是否 Up
|
||||
make docker-ps
|
||||
docker compose ps -a
|
||||
|
||||
# 查看日志
|
||||
make docker-logs
|
||||
|
||||
# 重启后端
|
||||
# 只重启后端
|
||||
docker compose restart backend
|
||||
|
||||
# 如果后端容器被重建过,Nginx 可能仍缓存旧 upstream IP;只需重启本项目 Nginx
|
||||
# 只重启 Web 网关
|
||||
docker compose restart nginx
|
||||
|
||||
# 停止本项目服务,但保留数据卷
|
||||
make docker-down
|
||||
# 停止本项目服务,保留数据库和前端构建卷
|
||||
make stop
|
||||
|
||||
# 清理本项目容器和数据卷,谨慎使用
|
||||
make clean-2
|
||||
# 清理本项目容器和数据卷,谨慎使用,会删除 PostgreSQL 数据
|
||||
make clean
|
||||
```
|
||||
|
||||
## 本地开发与测试
|
||||
@ -253,7 +272,8 @@ docker compose -f backend/docker-compose.yml --profile mock up -d backend-mock
|
||||
## 注意事项
|
||||
|
||||
- 不要为了端口冲突停止其他项目;优先通过 `WEB_HTTP_PORT`、`WEB_HTTPS_PORT`、`BACKEND_PORT`、`POSTGRES_PORT` 换端口。当前默认端口已经是 `18080/18443/18081/15432`。
|
||||
- 如果旧文档提到 `make docker-dev`、`make docker-prod`,现在这些命令仍可用,都会启动同一套 Docker 栈。
|
||||
- `frontend-build` 是一次性构建任务,退出码 `0` 是正常状态;前端页面由 `nginx` 容器提供。若只看到 backend/postgres 在运行,请执行 `make up` 或 `docker compose up --build -d` 恢复完整栈。
|
||||
- 如果旧文档提到 `make docker-dev`、`make docker-prod`,现在这些命令仍可用,都会调用 `make up` 启动同一套 Docker 栈。
|
||||
- 如果之前用旧配置启动失败过,PostgreSQL 卷里可能残留旧的加密数据,表现为 `/api/v1/clusters` 或 `/api/v1/registries` 解密失败。开发/重装环境可执行 `make clean-2 && make docker-dev` 重新初始化;生产环境不要直接删卷,应先备份数据库。
|
||||
- `vllm-serve` 必须以 Helm Chart OCI artifact 的形式存在于 Harbor 中;后端会寻找 Helm Chart layer 并保存为 `.tgz`。
|
||||
- Harbor 浏览使用 `/api/v2.0/projects`、project repositories 和 artifacts API。若 robot 账号无法列项目或 artifacts,页面会显示明确错误;请检查 Harbor 项目成员/robot 权限,而不是给普通用户开放全局 catalog。
|
||||
|
||||
Reference in New Issue
Block a user