一站式大数据组件部署、运维与监控平台,支持 HDFS、Spark、Flink、StarRocks 的自动化部署与统一管理。
PolarisData/
├── cmd/
│ ├── polaris-api/ # API 服务器入口 (~30行,只解析flags调用app.Run)
│ │ ├── main.go
│ │ └── frontend_embed.go # //go:embed 前端静态资源
│ └── polaris-web/ # StarRocks Web UI (独立)
├── internal/ # 业务逻辑层(按领域分模块,每模块 handler/service/routes/model)
│ ├── app/ # ⭐ 统一组装入口(DI + 生命周期管理)
│ │ ├── app.go # App struct + Config + New() + Run()
│ │ ├── router.go # 全局路由注册 + 中间件 + 前端serve
│ │ ├── agent.go # Agent 模式循环(采集上报)
│ │ └── clone.go # 数据克隆/Seed
│ ├── cluster/ # 集群/节点/组件 CRUD + 启停控制
│ │ ├── service.go # 业务逻辑 (ClusterService/NodeService/ComponentControlService)
│ │ ├── handler.go # HTTP handler 层
│ │ ├── routes.go # 路由注册
│ │ └── model.go # 请求/响应 DTO
│ ├── deploy/ # 部署引擎
│ │ ├── engine.go # DeployEngine 业务逻辑
│ │ ├── handler.go # HTTP handler
│ │ ├── routes.go # 路由注册
│ │ └── ansible_engine.go
│ ├── alert/ # 告警管理
│ │ ├── handler.go # AlertService 业务逻辑
│ │ ├── handler_http.go # HTTP handler
│ │ └── routes.go # 路由注册
│ ├── bootstrap/ # 集群发现/SSH检查/数据dump/seed/agent
│ │ ├── handler.go # BootstrapHandler HTTP handler
│ │ ├── routes.go # 路由注册
│ │ ├── discovery.go # 本地 kubeconfig 发现
│ │ ├── ssh_check.go # SSH 连通性检查
│ │ └── platform.go # 平台自部署组件
│ ├── config/ # 配置管理(读取/修改/版本/回滚/推送)
│ ├── log/ # 日志检索服务
│ ├── monitor/ # 组件健康/指标/进程 + 资源监控
│ ├── flink/ # Flink 组件管理器 (K8s)
│ ├── hdfs/ # HDFS 组件管理器 (K8s)
│ ├── spark/ # Spark 组件管理器 (K8s)
│ ├── starrocks/ # StarRocks 组件管理器 (K8s)
│ └── visualization/ # 组件 UI 代理/嵌入/快捷操作
├── pkg/ # 公共包
│ ├── api/ # Chi 路由/中间件/Response/Pagination
│ ├── db/ # GORM 模型 + SQLite 数据库
│ ├── frontend/ # 前端静态资源 embed 加载
│ ├── plugin/ # Component 接口 + Registry
│ └── resource/ # K8s 客户端/Apply引擎/健康检查/YAML加载
├── web/ # React + Ant Design 前端
│ ├── src/
│ │ ├── api/ # axios API 客户端
│ │ ├── layouts/ # 主布局 (侧边栏+Header)
│ │ ├── pages/ # 8 个页面
│ │ └── App.jsx # 路由配置
│ └── vite.config.js # Vite + API 代理
├── deploy/
│ ├── ansible/ # 物理机 Ansible Playbooks
│ └── monitoring/ # Docker Compose 监控栈
├── manifests/ # K8s manifests / Helm Charts
└── main.go # CLI 入口 (StarRocks 安装演示)
# 安装依赖 (无需 C 编译器, 使用纯 Go SQLite 驱动)
cd BigData
go run ./cmd/polaris-api --port 8080 --db polarisdata.db可选参数:
--portHTTP 端口 (默认 8080)--db数据库路径 (默认 polarisdata.db)--namespaceK8s namespace (默认 polarisdata)--version组件版本 (默认 latest)--dev-frontend代理前端到 Vite dev server (localhost:5173)
cd BigData/web
npm install
npm run dev浏览器访问 http://localhost:3000,API 请求自动代理到 localhost:8080。
cd BigData/deploy/monitoring
docker-compose up -d启动后访问:
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3001 (admin/polarisdata)
- Alertmanager: http://localhost:9093
# 修改 inventory.ini 中的主机 IP
cd BigData/deploy/ansible/hdfs
ansible-playbook -i inventory.ini deploy.yml
# 同理部署 Spark/Flink/StarRocks
cd BigData/deploy/ansible/spark
ansible-playbook -i inventory.ini deploy.yml# 需配置 KUBECONFIG 环境变量
helm install hdfs manifests/hdfs/
helm install spark manifests/spark/
helm install flink manifests/flink/| 模块 | 路径 | 说明 |
|---|---|---|
| 健康 | /api/v1/health |
服务健康检查 |
| 注册表 | /api/v1/registry |
已注册组件列表 |
| 集群 | /api/clusters |
集群 CRUD |
| 集群 | /api/clusters/{id}/nodes |
节点管理 |
| 集群 | `/api/clusters/{id}/components/start | stop |
| 部署 | /api/v1/deploy/{clusterID} |
一键部署 |
| 部署 | /api/v1/deploy/{clusterID}/status |
部署状态 |
| 部署 | /api/v1/deploy/{clusterID}/logs/stream |
部署日志 SSE |
| 部署 | /api/v1/deploy/versions |
版本兼容矩阵 |
| 配置 | /api/v1/config/{clusterID}/{component}/{file} |
配置读取/修改 |
| 配置 | `.../versions | compare |
| 监控 | `/api/v1/monitor/{clusterID}/health | metrics |
| 监控 | `/monitor/resource/overview | node |
| 可视化 | `/api/v1/clusters/{id}/visualization/ui | embedded` |
| 可视化 | `.../spark/submit | flink/submit |
| 告警 | `/api/v1/alerts/rules | history |
| 日志 | /api/v1/logs |
日志检索 |
# 基本验证
Invoke-WebRequest http://localhost:8080/api/v1/health
# 创建集群
$body = @{name="test-cluster"; environment="development"; deploy_mode="ansible"} | ConvertTo-Json
Invoke-WebRequest -Uri http://localhost:8080/api/clusters -Method POST -Body $body -ContentType "application/json"
# 查看版本矩阵
Invoke-WebRequest http://localhost:8080/api/v1/deploy/versions