集群 API
获取集群列表
请求
GET /api/clusters
查询参数
| 参数 | 类型 | 说明 |
|---|---|---|
| page | int | 页码,默认 1 |
| pageSize | int | 每页数量,默认 20 |
| search | string | 搜索关键字 |
| status | string | 状态筛选 |
示例
curl -X GET "https://kubepolaris.example.com/api/clusters?page=1&pageSize=10" \
-H "Authorization: Bearer <token>"
响应
{
"code": 200,
"data": {
"items": [
{
"id": 1,
"name": "production",
"apiServer": "https://k8s.example.com:6443",
"status": "connected",
"version": "v1.28.0",
"nodeCount": 5,
"createdAt": "2026-01-01T00:00:00Z"
}
],
"total": 1,
"page": 1,
"pageSize": 10
}
}
获取集群详情
请求
GET /api/clusters/:id
示例
curl -X GET https://kubepolaris.example.com/api/clusters/1 \
-H "Authorization: Bearer <token>"
响应
{
"code": 200,
"data": {
"id": 1,
"name": "production",
"description": "生产环境集群",
"apiServer": "https://k8s.example.com:6443",
"status": "connected",
"version": "v1.28.0",
"nodeCount": 5,
"podCount": 120,
"namespaceCount": 15,
"resources": {
"cpu": {
"capacity": "40",
"used": "25.5",
"percentage": 63.75
},
"memory": {
"capacity": "160Gi",
"used": "95Gi",
"percentage": 59.37
}
},
"createdAt": "2026-01-01T00:00:00Z",
"updatedAt": "2026-01-07T10:00:00Z"
}
}
创建集群
请求
POST /api/clusters