调整沙箱实例资源
更新时间:2026-11-17
接口描述
调整运行中 Kata 沙箱实例的容器 CPU 和内存资源(垂直扩缩容)。仅 runtimeType 为 kata 的沙箱支持。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,运行成功后可自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /sandboxes/{sandboxID}/resources HTTP/1.1
2Host: api.sandbox-execute.bj.baidubce.com
3Authorization: authorization string
4Content-Type: application/json
请求头域
除公共头域外,无其他特殊头域。Authorization 支持 IAM API Key(Bearer bce-v3/ALTAK-...)或 AK/SK 签名(bce-auth-v1/...)。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| sandboxID | String | 是 | URL参数 | 沙箱实例 ID。 |
| containers | List |
是 | RequestBody参数 | 要调整资源的容器列表。 |
返回状态码
成功返回 200。请求体非法返回 400;沙箱未运行返回 404(sandbox is not running);非 Kata 沙箱返回 409(NOT_KATA_SANDBOX);沙箱非 running 状态或调整被拒绝返回 409;认证失败返回 403。
返回头域
除公共头域外,无其他特殊头域。
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| sandboxID | String | 沙箱实例 ID。 |
| runtimeType | String | 运行时类型,固定为 kata。 |
| status | String | 调整状态:Completed、Pending、Resizing、Infeasible、Failed。 |
| containers | List |
各容器的资源状态。 |
| conditions | List |
资源调整条件,可能省略。 |
| message | String | 状态说明,可能省略。 |
请求示例
Plain Text
1POST /sandboxes/sandbox-1/resources HTTP/1.1
2Host: api.sandbox-execute.bj.baidubce.com
3Authorization: authorization string
4Content-Type: application/json
5
6{
7 "containers": [
8 {
9 "name": "sandbox",
10 "requests": {"cpu": "2", "memory": "2Gi"},
11 "limits": {"cpu": "2", "memory": "2Gi"}
12 }
13 ]
14}
响应示例
Plain Text
1HTTP/1.1 200 OK
2Content-Type: application/json
3
4{
5 "sandboxID": "sandbox-1",
6 "runtimeType": "kata",
7 "status": "Resizing",
8 "containers": [
9 {
10 "name": "sandbox",
11 "desired": {"cpu": "2", "memory": "2Gi"},
12 "allocated": {"cpu": "1", "memory": "1Gi"},
13 "current": {"cpu": "1", "memory": "1Gi"}
14 }
15 ]
16}
评价此篇文章
