FastClaw - K8s 多租户平台
约 802 字大约 3 分钟
2026-03-07
Kubernetes 托管服务后端,CRD 算力动态调度,商业化运营平台。
核心特性
Kubernetes 原生
- CRD 自定义资源
- Operator 模式
- 声明式 API
- 云原生架构
多租户支持
- 租户隔离
- 资源配额
- 配额管理
- 计费计量
动态调度
- 算力池管理
- 自动扩缩容
- 负载均衡
- 优先级调度
商业化运营
- 用户管理
- 配额套餐
- 计费系统
- 使用统计
快速开始
安装
# 安装 Operator
kubectl apply -f https://github.com/fastclaw/fastclaw/releases/latest/download/install.yaml
# Helm 安装
helm repo add fastclaw https://fastclaw.github.io/charts
helm install fastclaw fastclaw/fastclaw创建租户
# tenant.yaml
apiVersion: fastclaw.io/v1
kind: Tenant
metadata:
name: my-tenant
spec:
plan: pro
quotas:
agents: 10
cpu: "20"
memory: 40Gi
storage: 100Gi
users:
- user@example.comkubectl apply -f tenant.yaml部署 Agent
# agent.yaml
apiVersion: fastclaw.io/v1
kind: Agent
metadata:
name: my-agent
spec:
tenantRef:
name: my-tenant
model: gpt-4
replicas: 2
resources:
requests:
cpu: "2"
memory: 4Gikubectl apply -f agent.yaml技术架构
系统架构
┌─────────────────────────────────────────────┐
│ API Server (REST) │
├─────────────────────────────────────────────┤
│ Operator Controller │
├──────────┬──────────┬──────────┬────────────┤
│ Tenant │ Agent │ Pool │ Billing │
│ Controller Controller Controller │
├──────────┴──────────┴──────────┴────────────┘
│ Kubernetes API │
├─────────────────────────────────────────────┤
│ Pod / Service / Ingress / PVC / CRD │
└─────────────────────────────────────────────┘CRD 定义
// Tenant CRD
type TenantSpec struct {
Plan string `json:"plan,omitempty"`
Quotas TenantQuotas `json:"quotas"`
Users []string `json:"users"`
Billing BillingConfig `json:"billing,omitempty"`
}
type TenantQuotas struct {
Agents int `json:"agents"`
CPU string `json:"cpu"`
Memory string `json:"memory"`
Storage string `json:"storage"`
}
// Agent CRD
type AgentSpec struct {
TenantRef LocalObjectReference `json:"tenantRef"`
Model string `json:"model"`
Replicas int32 `json:"replicas"`
Resources ResourceRequirements `json:"resources"`
Config map[string]string `json:"config,omitempty"`
}Operator 逻辑
// Tenant Controller
func (r *TenantReconciler) Reconcile(ctx context.Context, req ctrl.Request) error {
// 1. 获取 Tenant
var tenant fastclawv1.Tenant
if err := r.Get(ctx, req.NamespacedName, &tenant); err != nil {
return err
}
// 2. 创建命名空间
ns := &corev1.Namespace{}
ns.Name = "tenant-" + tenant.Name
r.Create(ctx, ns)
// 3. 创建资源配额
quota := &corev1.ResourceQuota{}
quota.Name = "quota-" + tenant.Name
quota.Namespace = ns.Name
quota.Spec = corev1.ResourceQuotaSpec{
Hard: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse(tenant.Spec.Quotas.CPU),
corev1.ResourceMemory: resource.MustParse(tenant.Spec.Quotas.Memory),
},
}
r.Create(ctx, quota)
return nil
}功能列表
租户管理
Agent 管理
调度
运营
使用示例
创建算力池
apiVersion: fastclaw.io/v1
kind: ComputePool
metadata:
name: gpu-pool
spec:
nodeSelector:
gpu: "true"
capacity:
gpu: 8
cpu: "64"
memory: 256Gi
pricing:
perHour: 10.00配置套餐
apiVersion: fastclaw.io/v1
kind: Plan
metadata:
name: pro
spec:
quotas:
agents: 50
cpu: "100"
memory: 200Gi
features:
- priority_scheduling
- dedicated_pool
- custom_domain
price:
monthly: 999.00监控
# 查看租户使用
kubectl get tenant-usage my-tenant
# 输出
# NAME CPU USED MEM USED AGENTS STORAGE
# my-tenant 15/20 CPU 30/40 Gi 8/10 50/100 Gi适用场景
推荐使用
- SaaS 平台: 提供 AI Agent 服务
- 企业内部: 多部门共享算力
- 算力租赁: 算力交易平台
- 多租户环境: 需要资源隔离
商业功能
计费模式
| 套餐 | 价格 | 配额 | 特性 |
|---|---|---|---|
| Free | 免费 | 5 Agent | 基础 |
| Pro | ¥999/月 | 50 Agent | 优先调度 |
| Enterprise | 定制 | 无限 | 专属集群 |
相关链接
- GitHub: fastclaw/fastclaw
- 文档: 使用文档
- Charts: Helm Charts