AirGate/README.md
seaislee1209 f76ab6bd97 docs: add README with system overview and usage guide
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 16:59:04 +08:00

80 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AirGate
火山引擎 IAM 子账号管控平台。独立部署,带管理界面,可通过 API 对接其他系统。
## 解决什么问题
火山引擎的 IAM 子账号没有消费限额功能子账号可以不受限地花光主账号余额。AirGate 通过额度划拨 + 阶梯告警 + 自动停用,实现对子账号的消费管控。
## 核心功能
| 功能 | 说明 |
|------|------|
| **子账号管理** | 创建 / 同步 / 停用 / 恢复 IAM 子账号 |
| **权限策略** | 查看 / 附加 / 移除 IAM 策略Ark、TOS 等) |
| **额度划拨** | 主账号给子账号划拨额度,支持追加和扣减 |
| **阶梯告警** | 消费达到额度的 50% / 80% / 90% 时飞书通知 |
| **自动停用** | 消费达到额度 100% 时自动停用子账号 |
| **消费监控** | 定时查询 Billing API按项目维度追踪消费 |
| **密钥安全** | 主账号 AK/SK 加密存储AES-256界面脱敏显示 |
## 使用前提
- 子账号的资源需要放在**独立的火山项目**下,消费才能按项目准确追踪
- 火山账单数据有 **1-2 天延迟**,划拨额度时建议预留余量
## 本地运行
```bash
# 1. 复制环境变量
cp .env.example .env
# 编辑 .env填入 AIRGATE_ENCRYPTION_KEY生成方式见文件内注释
# 2. 启动后端
cd backend
python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver 8101
# 3. 启动前端(另一个终端)
cd frontend
npm install
npm run dev
```
打开 `http://localhost:5174`,登录后:
1. **系统设置** → 添加火山主账号(填 AK/SK加密存储
2. **子账号管理** → 同步已有用户 或 创建新子账号
3. 给子账号点 **划拨** → 设置额度
4.**更多 → 监控配置** → 选关联项目 + 设告警阶梯
## Docker 部署
```bash
docker-compose up -d
```
- 前端:`http://localhost:5174`
- 后端:`http://localhost:8101`
## 外部系统对接
AirDrama 等外部系统可通过 API Key 调用 AirGate 接口:
```bash
curl -H "X-API-Key: 你的key" http://airgate:8101/api/v1/iam-users/
```
`.env` 中设置 `AIRGATE_API_KEY` 启用。
## 技术栈
- 后端Django 4.2 + DRF + APScheduler
- 前端Vue 3 + Element Plus
- 加密cryptography (Fernet)
- 部署Docker + Nginx