feat(frontend): add Helm chart browser, monitoring, chart-references and values templates pages
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.
This commit is contained in:
457
README.md
457
README.md
@ -1,336 +1,201 @@
|
||||
# OCDP - Open Cloud Development Platform
|
||||
# OCDP - Open Cloud Deployment Platform
|
||||
|
||||
[](LICENSE)
|
||||
[](https://go.dev/)
|
||||
[](https://nodejs.org/)
|
||||
[](https://www.docker.com/)
|
||||
开源云原生部署平台,支持从 Harbor(或其他 OCI Registry)拉取 Helm Charts 并一键部署到多个 Kubernetes 集群。
|
||||
|
||||
开源云原生开发平台,用于管理 Kubernetes 集群、OCI Registry 和 Helm Charts 部署。
|
||||
## 功能特性
|
||||
|
||||
---
|
||||
- **多集群管理** - 支持多个 kubeconfig,管理多个 K8S 集群
|
||||
- **Registry 管理** - 支持 Harbor、Docker Registry、OCI 标准仓库
|
||||
- **多租户支持** - Workspace 隔离,管理员和普通用户角色
|
||||
- **存储后端** - NFS/PV/hostPath 存储配置管理
|
||||
- **Chart 引用** - 管理可用的 Helm Charts
|
||||
- **Values 模板** - 版本控制、支持回滚的配置模板
|
||||
- **一键部署** - 从 Harbor 拉取 Charts 部署到指定集群
|
||||
- **实例管理** - 支持升级、回滚、卸载 Helm Release
|
||||
- **状态监控** - 实时同步 Helm Release 状态
|
||||
|
||||
## ✨ 特性
|
||||
## 技术栈
|
||||
|
||||
- 🎯 **Registry 管理** - 支持 Harbor、Docker Registry、OCI 标准仓库
|
||||
- 📦 **Artifact 浏览** - 浏览和管理 Helm Charts、容器镜像
|
||||
- 🚀 **一键部署** - 可视化部署 Helm Charts 到 Kubernetes 集群
|
||||
- 🔍 **智能过滤** - 按 MediaType 过滤 artifacts(chart、image、other)
|
||||
- 🎨 **现代 UI** - 响应式设计,基于 React + TypeScript
|
||||
- 🔐 **安全认证** - JWT 认证,加密存储敏感信息
|
||||
- 🐳 **容器化** - 完整的 Docker 支持,多种运行模式
|
||||
- 🔄 **热重载** - 开发模式支持代码热重载
|
||||
| 层级 | 技术 |
|
||||
|------|------|
|
||||
| 后端 | Go 1.21+, Hexagonal Architecture |
|
||||
| 前端 | React 18, TypeScript, Next.js, TailwindCSS |
|
||||
| 数据库 | PostgreSQL |
|
||||
| 网关 | Nginx |
|
||||
|
||||
---
|
||||
## 快速开始
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 前置要求
|
||||
|
||||
- Docker 20.10+
|
||||
- Docker Compose 2.0+
|
||||
- (可选) Make 工具
|
||||
|
||||
### 5分钟快速体验
|
||||
### Docker Compose 启动(推荐)
|
||||
|
||||
```bash
|
||||
# 1. 克隆项目
|
||||
git clone <repository-url>
|
||||
cd ocdp-go
|
||||
# 1. 完全停止并清理现有容器
|
||||
docker compose -f docker-compose.yml -f backend/docker-compose.yml down -v
|
||||
|
||||
# 2. 启动开发环境(Mock 模式,无需数据库)
|
||||
make docker-dev
|
||||
# 2. 启动所有服务(PostgreSQL + Backend + Frontend + Nginx)
|
||||
ALLOWED_DEV_ORIGINS="http://10.6.80.114:3000" \
|
||||
NEXT_PUBLIC_API_URL="http://10.6.80.114:8080/api/v1" \
|
||||
BACKEND_PORT=8080 \
|
||||
docker compose -f docker-compose.yml -f backend/docker-compose.yml --profile backend up -d
|
||||
|
||||
# 3. 访问应用
|
||||
# - 前端:http://localhost:5173
|
||||
# - 后端:http://localhost:8080
|
||||
# - 默认账号:admin / admin123
|
||||
# 3. 查看服务状态
|
||||
docker ps
|
||||
|
||||
# 4. 访问
|
||||
# 前端: http://10.6.80.114
|
||||
# 后端: http://10.6.80.114:8080/api/v1
|
||||
# 默认账号: admin / admin123
|
||||
|
||||
# 停止服务
|
||||
docker compose -f docker-compose.yml -f backend/docker-compose.yml down
|
||||
```
|
||||
|
||||
**详细指南**:查看 [快速开始指南](./QUICK_START.md)
|
||||
### 开发环境
|
||||
|
||||
---
|
||||
```bash
|
||||
# 1. 确保 PostgreSQL 运行在 localhost:5432
|
||||
# 启动 PostgreSQL 容器:
|
||||
# docker run -d --name ocdp-postgres -e POSTGRES_DB=ocdp -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:15
|
||||
|
||||
## 📚 文档导航
|
||||
# 2. 初始化数据库(首次运行)
|
||||
# 方法一:手动执行 SQL
|
||||
cat backend/scripts/init-db.sql | docker exec -i ocdp-postgres psql -U postgres -d ocdp
|
||||
|
||||
### 📖 核心文档(必读)
|
||||
- 🚀 [快速开始](./QUICK_START.md) - 5分钟快速上手
|
||||
- 📋 [使用指南](./USAGE_GUIDE.md) - 详细使用说明(推荐)
|
||||
- 💡 [命令速查表](./COMMANDS_CHEATSHEET.md) - 常用命令快速参考
|
||||
- 📚 [文档中心](./docs/README.md) - 完整文档索引
|
||||
# 方法二:使用 Make(需确保 PostgreSQL 容器名为 ocdp-postgres)
|
||||
make db-init
|
||||
|
||||
### 🔧 专业文档
|
||||
- 📐 [开发规范](./docs/development/specification.md) - 代码规范和架构
|
||||
- 🚢 [部署指南](./docs/deployment/docker-guide.md) - 生产环境部署
|
||||
- 🔒 [安全实践](./docs/security/security-implementation.md) - 安全配置
|
||||
- 🎨 [功能文档](./docs/features/) - 详细功能说明
|
||||
# 3. 启动后端(需要设置环境变量)
|
||||
cd backend && \
|
||||
DATABASE_URL="postgres://postgres:postgres@localhost:5432/ocdp?sslmode=disable" \
|
||||
JWT_SECRET="test-jwt-secret-key" \
|
||||
ENCRYPTION_KEY="test-encryption-key-32-bytes-long" \
|
||||
PORT=8081 \
|
||||
ALLOWED_DEV_ORIGINS="10.6.80.114,localhost,127.0.0.1" \
|
||||
go run cmd/api/main.go
|
||||
|
||||
### 🔗 其他资源
|
||||
- 📋 [OpenAPI 规范](./backend/docs/openapi.yaml) - RESTful API 定义
|
||||
- 📦 [历史文档](./docs/archive/) - 项目演进历史
|
||||
# 4. 启动前端(需要 Node.js 20)
|
||||
source ~/.nvm/nvm.sh && nvm use 20
|
||||
cd frontend && NEXT_PUBLIC_API_URL=http://10.6.80.114:8081/api/v1 npm run dev
|
||||
|
||||
---
|
||||
# 5. 从外部访问
|
||||
# 本机访问: http://localhost:3000
|
||||
# 外部访问: http://10.6.80.114:3000
|
||||
# 默认账号: admin / admin123
|
||||
|
||||
## 🏗️ 技术架构
|
||||
# ===== 一键启动脚本 =====
|
||||
# 启动所有服务(后台运行)
|
||||
./start.sh
|
||||
|
||||
### 技术栈
|
||||
|
||||
**后端**:
|
||||
- Go 1.24+ (Hexagonal Architecture)
|
||||
- PostgreSQL 16
|
||||
- Redis 7
|
||||
|
||||
**前端**:
|
||||
- React 18
|
||||
- TypeScript 5
|
||||
- Vite 6
|
||||
- TailwindCSS 3
|
||||
|
||||
**容器化**:
|
||||
- Docker
|
||||
- Docker Compose
|
||||
- Multi-stage builds
|
||||
|
||||
### 架构图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Frontend │
|
||||
│ React + TypeScript + Vite │
|
||||
└──────────────────────────┬──────────────────────────────────┘
|
||||
│ HTTP/REST
|
||||
┌──────────────────────────┼──────────────────────────────────┐
|
||||
│ │ Backend API │
|
||||
│ ▼ │
|
||||
│ ┌─────────────────────┐ │
|
||||
│ │ Input Adapters │ │
|
||||
│ │ (REST/GraphQL) │ │
|
||||
│ └──────────┬──────────┘ │
|
||||
│ │ │
|
||||
│ ┌──────────▼──────────┐ │
|
||||
│ │ Domain Services │ │
|
||||
│ │ (Business Logic) │ │
|
||||
│ └──────────┬──────────┘ │
|
||||
│ │ │
|
||||
│ ┌──────────▼──────────┐ │
|
||||
│ │ Output Adapters │ │
|
||||
│ │ (Repos/Clients) │ │
|
||||
│ └──────────┬──────────┘ │
|
||||
└───────────────────────┼─┴────────────────────────────────┘
|
||||
│
|
||||
┌───────────────┼───────────────┐
|
||||
│ │ │
|
||||
┌────▼────┐ ┌────▼────┐ ┌────▼────┐
|
||||
│ PG DB │ │ Redis │ │ OCI │
|
||||
│ │ │ │ │ Registry│
|
||||
└─────────┘ └─────────┘ └─────────┘
|
||||
# 停止所有服务
|
||||
./stop.sh
|
||||
```
|
||||
|
||||
### 运行模式
|
||||
### 生产环境(Docker Compose)
|
||||
|
||||
| 模式 | 特点 | 适用场景 | 命令 |
|
||||
|------|------|----------|------|
|
||||
| **开发模式** | Mock 数据,热重载 | 日常开发 | `make docker-dev` |
|
||||
| **生产模式** | 真实数据库,完整功能 | 生产部署 | `make docker-prod` |
|
||||
| **Mock 模式** | 独立测试单个服务 | 单元测试 | `make docker-test-backend` |
|
||||
```bash
|
||||
# 构建并启动所有服务
|
||||
make run-2
|
||||
|
||||
---
|
||||
# 停止服务
|
||||
make clean-2
|
||||
```
|
||||
|
||||
## 🛠️ 开发指南
|
||||
## 配置
|
||||
|
||||
### 项目结构
|
||||
### 环境变量
|
||||
|
||||
| 变量 | 默认值 | 说明 |
|
||||
|------|--------|------|
|
||||
| DATABASE_URL | postgres://postgres:postgres@localhost:5432/ocdp?sslmode=disable | 数据库连接串 |
|
||||
| PORT | 8080 | 后端端口 |
|
||||
| BACKEND_PORT | 8080 | Docker 映射端口 |
|
||||
| JWT_SECRET | change-me-in-production | JWT 密钥 |
|
||||
| ENCRYPTION_KEY | change-me-32-bytes-long-key-here | 加密密钥 |
|
||||
| ALLOWED_DEV_ORIGINS | http://10.6.80.114:3000 | 允许的跨域来源(外部访问时需要配置)|
|
||||
| NEXT_PUBLIC_API_URL | http://10.6.80.114:8080/api/v1 | 前端调用的API地址 |
|
||||
|
||||
### 配置文件
|
||||
|
||||
项目根目录 `.env` 文件包含默认配置:
|
||||
- Kubernetes 集群配置
|
||||
- Harbor 仓库信息
|
||||
- NFS 存储配置
|
||||
|
||||
## 访问
|
||||
|
||||
| 服务 | 地址 |
|
||||
|------|------|
|
||||
| 前端 (Nginx) | http://10.6.80.114 |
|
||||
| 后端 API | http://10.6.80.114:8080/api/v1 |
|
||||
| API 文档 | http://10.6.80.114:8080/api/docs |
|
||||
|
||||
**默认账号**: `admin` / `admin123`
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
ocdp-go/
|
||||
├── backend/ # Go 后端服务
|
||||
│ ├── cmd/api/ # 应用入口
|
||||
│ ├── internal/ # 内部代码
|
||||
│ │ ├── adapter/ # 适配器层
|
||||
│ │ ├── domain/ # 领域层
|
||||
│ │ └── bootstrap/ # 启动配置
|
||||
│ ├── Dockerfile # 生产环境
|
||||
│ ├── Dockerfile.dev # 开发环境
|
||||
│ └── Dockerfile.mock # Mock 测试
|
||||
│
|
||||
├── frontend/ # React 前端应用
|
||||
├── backend/ # Go 后端 (Hexagonal Architecture)
|
||||
│ ├── cmd/api/ # 入口点
|
||||
│ ├── internal/
|
||||
│ │ ├── adapter/ # 适配器层 (HTTP, Persistence)
|
||||
│ │ ├── domain/ # 领域层 (Entity, Service, Repository)
|
||||
│ │ └── bootstrap/ # 初始化和种子数据
|
||||
│ └── scripts/ # 脚本 (init-db.sql)
|
||||
├── frontend/ # Next.js 前端
|
||||
│ ├── src/
|
||||
│ │ ├── core/ # 核心功能
|
||||
│ │ ├── features/ # 功能模块
|
||||
│ │ └── shared/ # 共享组件
|
||||
│ ├── Dockerfile # 生产环境
|
||||
│ ├── Dockerfile.dev # 开发环境
|
||||
│ └── Dockerfile.mock # Mock 测试
|
||||
│
|
||||
├── api/ # API 规范
|
||||
│ └── openapi.yaml # OpenAPI 定义
|
||||
│
|
||||
├── docs/ # 项目文档
|
||||
│ ├── features/ # 功能文档
|
||||
│ ├── deployment/ # 部署文档
|
||||
│ └── development/ # 开发文档
|
||||
│
|
||||
├── docker-compose.yml # 统一配置(使用 profiles)
|
||||
└── Makefile # 便捷命令
|
||||
│ │ ├── app/ # 页面路由
|
||||
│ │ ├── components/ # 组件
|
||||
│ │ └── lib/ # 工具库 (API, types, auth)
|
||||
│ └── .env.local # 前端环境配置
|
||||
├── infra/nginx/ # Nginx 配置
|
||||
├── docker-compose.yml # 主配置
|
||||
├── backend/docker-compose.yml # 后端配置
|
||||
└── Makefile # 构建命令
|
||||
```
|
||||
|
||||
### 常用命令
|
||||
## 核心 API
|
||||
|
||||
| 模块 | 端点 | 说明 |
|
||||
|------|------|------|
|
||||
| 认证 | POST /api/v1/auth/login | 用户登录 |
|
||||
| 用户 | GET/POST /api/v1/users | 用户管理 |
|
||||
| Workspaces | GET/POST /api/v1/workspaces | 工作空间管理 |
|
||||
| Clusters | GET/POST /api/v1/clusters | 集群管理 |
|
||||
| Registries | GET/POST /api/v1/registries | 镜像仓库管理 |
|
||||
| Storage | GET/POST /api/v1/storage-backends | 存储后端管理 |
|
||||
| Chart References | GET/POST /api/v1/chart-references | Chart 引用管理 |
|
||||
| Values Templates | GET/POST /api/v1/values-templates | 配置模板管理 |
|
||||
| Instances | GET/POST/DELETE /api/v1/instances | 实例部署管理 |
|
||||
|
||||
## 权限模型
|
||||
|
||||
- **Admin** - 管理员,可管理所有资源和用户
|
||||
- **User** - 普通用户,仅可访问所属 Workspace 的资源
|
||||
|
||||
## 开发命令
|
||||
|
||||
```bash
|
||||
# Docker 服务(推荐)
|
||||
make docker-dev # 启动开发环境
|
||||
make docker-prod # 启动生产环境
|
||||
make docker-test-backend # 测试后端
|
||||
make docker-test-frontend # 测试前端
|
||||
make docker-logs # 查看日志
|
||||
make docker-down # 停止服务
|
||||
# 启动开发服务器
|
||||
make dev # 同时启动前后端
|
||||
make dev-backend # 仅后端
|
||||
make dev-frontend # 仅前端
|
||||
|
||||
# OpenAPI 工作流
|
||||
make openapi-validate # 验证 API 规范
|
||||
make openapi-gen # 生成代码
|
||||
make openapi-docs # 生成文档
|
||||
# 数据库操作
|
||||
make db-init # 初始化数据库
|
||||
make db-reset # 重置数据库
|
||||
make db-shell # 打开数据库 shell
|
||||
|
||||
# 本地开发(不使用 Docker)
|
||||
make install # 安装依赖
|
||||
make dev-local # 启动本地开发
|
||||
make test # 运行测试
|
||||
# Docker 构建
|
||||
make build # 构建所有镜像
|
||||
make build-backend # 构建后端镜像
|
||||
make build-frontend # 构建前端镜像
|
||||
|
||||
# 日志和调试
|
||||
make logs # 查看所有日志
|
||||
make logs-backend # 后端日志
|
||||
make stop # 停止开发服务器
|
||||
```
|
||||
|
||||
### 开发工作流
|
||||
## License
|
||||
|
||||
1. **启动开发环境**:
|
||||
```bash
|
||||
make docker-dev
|
||||
```
|
||||
|
||||
2. **修改代码**(自动热重载):
|
||||
- 后端:编辑 `backend/` 下的 Go 文件
|
||||
- 前端:编辑 `frontend/src/` 下的 React 组件
|
||||
|
||||
3. **查看日志**:
|
||||
```bash
|
||||
make docker-logs
|
||||
```
|
||||
|
||||
4. **测试功能**:
|
||||
- 前端:http://localhost:5173
|
||||
- 后端:http://localhost:8080
|
||||
|
||||
5. **提交代码**:
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "feat: add new feature"
|
||||
git push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧪 测试
|
||||
|
||||
### 后端测试
|
||||
|
||||
```bash
|
||||
# 启动后端 Mock
|
||||
make docker-test-backend-bg
|
||||
|
||||
# 测试健康检查
|
||||
curl http://localhost:8080/health
|
||||
|
||||
# 测试登录
|
||||
curl -X POST http://localhost:8080/api/v1/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"admin","password":"admin123"}'
|
||||
|
||||
# 测试 API
|
||||
curl http://localhost:8080/api/v1/registries
|
||||
curl http://localhost:8080/api/v1/clusters
|
||||
```
|
||||
|
||||
### 前端测试
|
||||
|
||||
```bash
|
||||
# 启动前端 Mock
|
||||
make docker-test-frontend-bg
|
||||
|
||||
# 访问前端
|
||||
open http://localhost:3000
|
||||
```
|
||||
|
||||
### 集成测试
|
||||
|
||||
```bash
|
||||
# 启动完整环境
|
||||
make docker-prod
|
||||
|
||||
# 运行测试套件
|
||||
make test
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📦 部署
|
||||
|
||||
### Docker Compose 部署(推荐)
|
||||
|
||||
```bash
|
||||
# 1. 配置环境变量
|
||||
export JWT_SECRET="your-production-secret"
|
||||
export ENCRYPTION_KEY="your-32-byte-encryption-key"
|
||||
|
||||
# 2. 启动服务
|
||||
docker compose up -d
|
||||
|
||||
# 3. 查看状态
|
||||
docker compose ps
|
||||
```
|
||||
|
||||
### Kubernetes 部署
|
||||
|
||||
查看 [Kubernetes 部署指南](./docs/deployment/kubernetes-guide.md)
|
||||
|
||||
---
|
||||
|
||||
## 🤝 贡献
|
||||
|
||||
欢迎贡献代码!请遵循以下步骤:
|
||||
|
||||
1. Fork 项目
|
||||
2. 创建功能分支 (`git checkout -b feature/amazing-feature`)
|
||||
3. 提交更改 (`git commit -m 'feat: add amazing feature'`)
|
||||
4. 推送分支 (`git push origin feature/amazing-feature`)
|
||||
5. 创建 Pull Request
|
||||
|
||||
### 开发规范
|
||||
|
||||
- **代码风格**:Go (gofmt),TypeScript (ESLint + Prettier)
|
||||
- **提交规范**:遵循 [Conventional Commits](https://www.conventionalcommits.org/)
|
||||
- **测试覆盖**:新功能必须包含测试
|
||||
|
||||
---
|
||||
|
||||
## 📄 许可证
|
||||
|
||||
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
|
||||
|
||||
---
|
||||
|
||||
## 🙏 致谢
|
||||
|
||||
- [Go](https://go.dev/) - 后端开发语言
|
||||
- [React](https://react.dev/) - 前端框架
|
||||
- [Vite](https://vitejs.dev/) - 构建工具
|
||||
- [Docker](https://www.docker.com/) - 容器化平台
|
||||
- [Kubernetes](https://kubernetes.io/) - 容器编排
|
||||
- [Harbor](https://goharbor.io/) - OCI Registry
|
||||
|
||||
---
|
||||
|
||||
## 📞 联系方式
|
||||
|
||||
- **项目主页**:https://github.com/your-org/ocdp-go
|
||||
- **问题反馈**:https://github.com/your-org/ocdp-go/issues
|
||||
- **文档网站**:https://docs.ocdp.example.com
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>Built with ❤️ by the OCDP Team</sub>
|
||||
</div>
|
||||
MIT
|
||||
Reference in New Issue
Block a user