Add new frontend pages for the multi-tenant OCDP platform: - Charts page (/charts): Browse Harbor OCI registries to list Helm chart repositories and versions, with deploy modal to launch charts on selected clusters - Monitoring page (/monitoring): Display cluster metrics (CPU/Memory/GPU usage) and per-node details with resource utilization bars - Chart References page (/chart-references): CRUD for chart metadata references - Values Templates page (/templates): CRUD for Helm values templates with version history and rollback support - Sidebar: Add Charts navigation, update Storage and Templates links - api.ts: Add all API client functions (clusterApi, registryApi, instanceApi, monitoringApi, storageApi, chartReferenceApi, valuesTemplateApi, workspaceApi, userApi) with full TypeScript types Note: deploy flow and values template rollback not yet end-to-end tested.
OCDP Backend
Go 后端服务,提供 Kubernetes Helm Chart 部署能力。
技术栈
- Go 1.21+
- gorilla/mux (HTTP 路由)
- ORAS Go SDK v2 (OCI 操作)
- Helm SDK (Helm 操作)
- Kubernetes client-go
- PostgreSQL
启动
# Mock 模式(无需数据库,无需外部服务)
ADAPTER_MODE=mock go run cmd/api/main.go
# 生产模式(需要 PostgreSQL + K8s/Harbor 连接验证)
# 启动 PostgreSQL
docker compose up -d postgres
# 启动后端(生产模式)
cd backend
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/ocdp?sslmode=disable"
export JWT_SECRET="your-jwt-secret"
export ENCRYPTION_KEY="your-32-byte-encryption-key"
export PORT=8081
export ADAPTER_MODE=production
export KUBECONFIG=/home/ivanwu/.kube/config # 或你的 kubeconfig 路径
# Harbor 凭证(可选,用于验证 Registry 连接)
export HARBOR_URL="https://harbor.bwgdi.com"
export HARBOR_USERNAME="your-harbor-user"
export HARBOR_PASSWORD="your-harbor-password"
# NFS 配置(可选)
export NFS_SERVER="10.6.80.11"
export NFS_SHARE="/volume1/NFS"
go run cmd/api/main.go
环境变量说明
| 变量 | 必需 | 说明 |
|---|---|---|
| DATABASE_URL | 是 | PostgreSQL 连接字符串 |
| JWT_SECRET | 是 | JWT 签名密钥 |
| ENCRYPTION_KEY | 是 | 32位加密密钥 |
| PORT | 否 | 服务端口,默认 8080 |
| ADAPTER_MODE | 否 | mock 或 production,默认 production |
| KUBECONFIG | 生产模式 | Kubernetes kubeconfig 文件路径 |
| HARBOR_URL | 否 | Harbor URL,用于 Registry 验证 |
| HARBOR_USERNAME | 否 | Harbor 用户名 |
| HARBOR_PASSWORD | 否 | Harbor 密码 |
连接验证
在生产模式下,创建 Cluster 或 Registry 时会自动验证连接:
- Cluster: 尝试使用提供的凭证连接 K8s API Server
- Registry: 尝试使用提供的凭证登录 Harbor
如果验证失败,创建会返回错误信息。
API 访问
- API: http://localhost:8081/api/v1
- Health: http://localhost:8081/health
- Swagger: http://localhost:8081/api/docs
项目结构
backend/
├── cmd/api/ # 入口
├── internal/
│ ├── domain/ # 领域层
│ │ ├── entity/ # 实体
│ │ ├── service/ # 业务逻辑
│ │ └── repository/ # 接口
│ ├── adapter/
│ │ ├── input/http/ # REST API
│ │ └── output/ # 数据库、OCI、Helm
│ └── bootstrap/ # 启动配置
└── docs/ # OpenAPI 规范