Skip to content

Commit 6d0211b

Browse files
committed
docs(kubernetes): enhance resource pool and task orchestration documentation
1 parent 7b68d18 commit 6d0211b

6 files changed

Lines changed: 43 additions & 37 deletions

File tree

kubernetes/README-ZH.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,29 @@ BatchSandbox 自定义资源允许您创建和管理多个相同的沙箱环境
2525

2626
### 资源池化
2727
Pool 自定义资源维护一个预热的计算资源池,以实现快速沙箱供应:
28-
- 可配置的缓冲区大小(最小和最大)以平衡资源可用性和成本
29-
- 池容量限制以控制总体资源消耗
30-
- 基于需求的自动资源分配和释放
31-
- 实时状态监控,显示总数、已分配和可用资源
28+
- **可配置的缓冲区大小**:设置最小和最大缓冲区,以确保资源可用性同时控制成本。
29+
- **池容量限制**:通过池范围的最小和最大限制来控制总体资源消耗。
30+
- **回收策略 (Recycle Policies)**:支持不同的 Pod 回收策略:
31+
- **Delete (默认)**:Pod 在返回池时会被删除并根据模板重新创建,确保环境绝对纯净。
32+
- **Restart**:通过向所有容器的 PID 1 发送 SIGTERM 信号优雅终止进程,并依赖 Kubernetes 的 `restartPolicy` 触发重启。这种方式比 `Delete` 更快,但要求 `PodTemplateSpec` 中的 `restartPolicy` 设置为 `Always``OnFailure`
33+
- **自动扩展**:基于当前需求和缓冲区设置进行动态资源分配和释放。
34+
- **实时状态监控**:显示总数、已分配、可用以及正在重启中的 Pod 数量。
3235

3336
### 任务编排
3437
集成的任务管理系统,在沙箱内执行自定义工作负载:
35-
- **可选执行**:任务调度完全可选 - 可以在不带任务的情况下创建沙箱
36-
- **基于进程的任务**:支持在沙箱环境中执行基于进程的任务
37-
- **异构任务分发**:使用 shardTaskPatches 为批处理中的每个沙箱定制单独的任务
38+
- **可选执行**:任务调度完全可选 - 可以在不带任务的情况下创建沙箱。
39+
- **基于进程的任务**:支持在沙箱环境中执行基于进程的任务。
40+
- **异构任务分发**:使用 `shardTaskPatches` 为批处理中的每个沙箱定制单独的任务。
41+
- **资源释放策略**:通过 `taskResourcePolicyWhenCompleted` 控制任务完成后资源何时返回池:
42+
- **Retain (默认)**:保持沙箱资源,直到 `BatchSandbox` 被删除或过期。
43+
- **Release**:在任务达到终态(SUCCEEDED 或 FAILED)后,立即自动将沙箱释放回资源池。
3844

3945
### 高级调度
4046
智能资源管理功能:
41-
- 最小和最大缓冲区设置,以确保资源可用性同时控制成本
42-
- 池范围的容量限制,防止资源耗尽
43-
- 基于需求的自动扩展
47+
- **基于需求的自动扩展**:根据实时的沙箱分配请求,自动扩展和收缩资源池中的 Pod 数量。
48+
- **缓冲区管理**:通过 `bufferMin``bufferMax` 设置平衡即时可用性与资源开销。
49+
- **池约束**:使用 `poolMin``poolMax` 设置资源使用的硬边界。
50+
- **滚动更新**:当修改 `PodTemplateSpec` 时,自动进行池更新和 Pod 轮转。
4451

4552
## 运行时 API 支持说明
4653

@@ -390,6 +397,7 @@ spec:
390397
bufferMin: 2
391398
poolMax: 20
392399
poolMin: 5
400+
podRecyclePolicy: Delete
393401
```
394402
395403
应用资源池配置:
@@ -442,6 +450,7 @@ spec:
442450
bufferMin: 2
443451
poolMax: 20
444452
poolMin: 5
453+
podRecyclePolicy: Delete
445454
```
446455
447456
使用我们刚刚创建的资源池创建一批带有基于进程的异构任务的沙箱:
@@ -454,6 +463,7 @@ metadata:
454463
spec:
455464
replicas: 2
456465
poolRef: task-example-pool
466+
taskResourcePolicyWhenCompleted: Release
457467
taskTemplate:
458468
spec:
459469
process:

kubernetes/README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,29 @@ The BatchSandbox custom resource allows you to create and manage multiple identi
2525

2626
### Resource Pooling
2727
The Pool custom resource maintains a pool of pre-warmed compute resources to enable rapid sandbox provisioning:
28-
- Configurable buffer sizes (minimum and maximum) to balance resource availability and cost
29-
- Pool capacity limits to control overall resource consumption
30-
- Automatic resource allocation and deallocation based on demand
31-
- Real-time status monitoring showing total, allocated, and available resources
28+
- **Configurable Buffer Sizes**: Minimum and maximum buffer settings to ensure resource availability while controlling costs.
29+
- **Pool Capacity Limits**: Overall resource consumption control with pool-wide minimum and maximum limits.
30+
- **Recycle Policies**: Support for different pod recycling strategies:
31+
- **Delete (Default)**: Pods are deleted and recreated from the template when returned to the pool, ensuring a completely clean environment.
32+
- **Restart**: PID 1 in all containers is gracefully terminated (SIGTERM), and the Kubernetes `restartPolicy` triggers a restart. This is faster than `Delete` but requires the `restartPolicy` in `PodTemplateSpec` to be set to `Always` or `OnFailure`.
33+
- **Automatic Scaling**: Dynamic resource allocation and deallocation based on current demand and buffer settings.
34+
- **Real-time Status**: Monitoring of total, allocated, available, and restarting pods.
3235

3336
### Task Orchestration
3437
Integrated task management system that executes custom workloads within sandboxes:
35-
- **Optional Execution**: Task scheduling is completely optional - sandboxes can be created without tasks
36-
- **Process-Based Tasks**: Support for process-based tasks that execute within the sandbox environment
37-
- **Heterogeneous Task Distribution**: Customize individual tasks for each sandbox in a batch using shardTaskPatches
38+
- **Optional Execution**: Task scheduling is completely optional - sandboxes can be created without tasks.
39+
- **Process-Based Tasks**: Support for process-based tasks that execute within the sandbox environment.
40+
- **Heterogeneous Task Distribution**: Customize individual tasks for each sandbox in a batch using `shardTaskPatches`.
41+
- **Resource Release Policy**: Control when resources are returned to the pool after task completion via `taskResourcePolicyWhenCompleted`:
42+
- **Retain (Default)**: Keeps the sandbox resources until the `BatchSandbox` is deleted or expires.
43+
- **Release**: Automatically releases the sandbox back to the pool immediately after the task reaches a terminal state (SUCCEEDED or FAILED).
3844

3945
### Advanced Scheduling
4046
Intelligent resource management features:
41-
- Minimum and maximum buffer settings to ensure resource availability while controlling costs
42-
- Pool-wide capacity limits to prevent resource exhaustion
43-
- Automatic scaling based on demand
47+
- **Demand-based Scaling**: Automatically scales the number of pods in the pool based on real-time sandbox allocation requests.
48+
- **Buffer Management**: `bufferMin` and `bufferMax` settings to balance instant availability with resource overhead.
49+
- **Pool Constraints**: `poolMin` and `poolMax` to set hard boundaries on resource usage.
50+
- **Rolling Updates**: Automatic pool update and pod rotation when the `PodTemplateSpec` is modified.
4451

4552
## Runtime API Support Notes
4653

@@ -389,6 +396,7 @@ spec:
389396
bufferMin: 2
390397
poolMax: 20
391398
poolMin: 5
399+
podRecyclePolicy: Delete
392400
```
393401
394402
Apply the pool configuration:
@@ -441,6 +449,7 @@ spec:
441449
bufferMin: 2
442450
poolMax: 20
443451
poolMin: 5
452+
podRecyclePolicy: Delete
444453
```
445454
446455
Create a batch of sandboxes with process-based heterogeneous tasks using the pool we just created:
@@ -453,6 +462,7 @@ metadata:
453462
spec:
454463
replicas: 2
455464
poolRef: task-example-pool
465+
taskResourcePolicyWhenCompleted: Release
456466
taskTemplate:
457467
spec:
458468
process:

kubernetes/charts/opensandbox-controller/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ spec:
186186
bufferMin: 2
187187
poolMax: 20
188188
poolMin: 5
189+
podRecyclePolicy: Delete
189190
```
190191
191192
### Create a Batch Sandbox

kubernetes/config/samples/sandbox_v1alpha1_batchsandbox-with-task.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ spec:
2121
- -f
2222
- /dev/null
2323
expireTime: "2025-12-03T12:55:41Z"
24+
taskResourcePolicyWhenCompleted: Release
2425
taskTemplate:
2526
spec:
2627
process:

kubernetes/config/samples/sandbox_v1alpha1_pool.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ spec:
7171
bufferMin: 1
7272
poolMax: 5
7373
poolMin: 0
74+
podRecyclePolicy: Delete

kubernetes/test/e2e/testdata/pool-with-restart-policy.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)