Go(Gin) + React(Vite + shadcn/ui + Tailwind) 前后端分离,全中文 UI - 集群管理:Kubeconfig / Token 双接入,kubectl + helm 部署 - 主机管理:SSH 密钥 / 密码双认证,CPU/内存/磁盘使用率监控,SSH 错误中文友好提示 - 存储配置、部署管理、系统设置 - Docker 镜像内置 kubectl + helm,开箱即用 - run.sh 一键启停(start/stop/restart/status) Co-Authored-By: Claude <noreply@anthropic.com>
134 lines
3.6 KiB
Markdown
134 lines
3.6 KiB
Markdown
# LokiDeploy - K8s Loki Deployment Platform
|
|
|
|
A lightweight **Gin + React + JSON file storage** platform for deploying Grafana Loki log aggregation on Kubernetes clusters or bare-metal hosts via SSH.
|
|
|
|
## Features
|
|
|
|
- **K8s Cluster Management** - Add clusters via kubeconfig, auto-validate connectivity
|
|
- **SSH Host Management** - Password or key-based authentication
|
|
- **Storage Configuration** - S3, OSS, MinIO, RustFS backends
|
|
- **One-Click Loki Deploy** - Helm chart / YAML manifest / Binary
|
|
- **Deployment Logs** - Real-time log streaming
|
|
- **Web Terminal** - Browser-based remote command execution
|
|
- **Single Binary** - 13MB zero-dependency executable
|
|
- **Security** - Argon2 password hashing, AES credential encryption, JWT auth
|
|
|
|
## Quick Start
|
|
|
|
### Prerequisites
|
|
- Linux/macOS with `kubectl` and `helm` installed (for K8s deployment)
|
|
- `curl` or `wget` on target hosts
|
|
- Go 1.23+ (for building from source)
|
|
- Node.js 20+ (for building frontend)
|
|
|
|
### Option 1: Build & Run (Recommended)
|
|
|
|
```bash
|
|
git clone https://github.com/your/lokideploy.git
|
|
cd lokideploy
|
|
|
|
# Build everything
|
|
bash build.sh
|
|
|
|
# Start frontend (:3000) + backend (:8080)
|
|
./run.sh
|
|
|
|
# Open http://localhost:3000
|
|
# Default: admin / admin123
|
|
```
|
|
|
|
### Option 2: Docker Compose
|
|
|
|
```bash
|
|
cd lokideploy
|
|
docker compose up -d
|
|
|
|
# Open http://localhost:8080
|
|
```
|
|
|
|
### Option 3: Development Mode (Hot Reload)
|
|
|
|
```bash
|
|
# Terminal 1 - Backend
|
|
cd backend
|
|
go run .
|
|
|
|
# Terminal 2 - Frontend
|
|
cd frontend
|
|
npm install
|
|
npm run dev
|
|
# Opens http://localhost:3000, proxies API to localhost:8080
|
|
```
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Frontend (React + TypeScript + Tailwind CSS) [Port 3000 dev / 8080 prod]
|
|
|
|
|
| HTTP/REST + JWT Bearer Token
|
|
v
|
|
Backend (Go + Gin) [Port 8080]
|
|
|
|
|
+---> JSON File DB (data/lokideploy.json)
|
|
+---> K8s CLI (kubectl / helm)
|
|
+---> SSH Client (golang.org/x/crypto/ssh)
|
|
+---> Loki Deployer (Helm Chart / YAML / Binary)
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
Base URL: `/api/v1`
|
|
|
|
| Method | Endpoint | Auth | Description |
|
|
|--------|----------|------|-------------|
|
|
| POST | `/auth/login` | No | Login, get JWT token |
|
|
| GET | `/auth/user` | Yes | Current user info |
|
|
| POST | `/auth/password` | Yes | Change password |
|
|
| GET/POST | `/clusters` | Yes | Cluster CRUD |
|
|
| POST | `/clusters/:id/validate` | Yes | Validate cluster |
|
|
| GET/POST | `/hosts` | Yes | Host CRUD |
|
|
| POST | `/hosts/:id/execute` | Yes | Remote command |
|
|
| GET/POST | `/storages` | Yes | Storage config CRUD |
|
|
| GET/POST | `/deployments` | Yes | Deployment CRUD |
|
|
| POST | `/deployments/:id/deploy` | Yes | Start deployment |
|
|
| POST | `/deployments/:id/stop` | Yes | Stop deployment |
|
|
| GET | `/deployments/:id/logs` | Yes | Deployment logs |
|
|
| GET | `/deployments/stats` | Yes | Statistics |
|
|
|
|
## Deployment Modes
|
|
|
|
| Mode | Target | Description |
|
|
|------|--------|-------------|
|
|
| `k8s-helm` | K8s Cluster | Official Grafana Helm chart |
|
|
| `k8s-yaml` | K8s Cluster | Raw Kubernetes manifests |
|
|
| `host-binary` | Linux Host | Binary + systemd via SSH |
|
|
|
|
## Storage Backends
|
|
|
|
| Type | Endpoint Example |
|
|
|------|-----------------|
|
|
| S3 | `s3.amazonaws.com` |
|
|
| OSS | `oss-cn-hangzhou.aliyuncs.com` |
|
|
| MinIO | `http://minio:9000` |
|
|
| RustFS | `http://rustfs:8080` |
|
|
|
|
## Environment Variables
|
|
|
|
| Variable | Default | Description |
|
|
|----------|---------|-------------|
|
|
| `SERVER_PORT` | `8080` | HTTP server port |
|
|
| `DATA_DIR` | `./data` | Data storage directory |
|
|
| `JWT_SECRET` | `lokideploy-secret-key...` | JWT signing key |
|
|
|
|
## Security
|
|
|
|
- **Argon2** password hashing
|
|
- **AES-GCM** credential encryption
|
|
- **JWT** token authentication
|
|
- **RBAC** role-based access control
|
|
- API responses sanitized (no passwords, kubeconfig, or keys exposed)
|
|
|
|
## License
|
|
|
|
MIT License
|