Skip to content

Commit 2b5b3a3

Browse files
committed
KEP for sandbox warmpool to create sandboxes
1 parent 2332dd1 commit 2b5b3a3

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# KEP-NNNN: Your short, descriptive title
2+
3+
<!--
4+
TOC is auto-generated via `make toc-update`.
5+
-->
6+
7+
<!-- toc -->
8+
- [Summary](#summary)
9+
- [Motivation](#motivation)
10+
- [Proposal](#proposal)
11+
- [User Stories (Optional)](#user-stories-optional)
12+
- [High-Level Design](#high-level-design)
13+
- [API Changes](#api-changes)
14+
- [Implementation Guidance](#implementation-guidance)
15+
- [Scalability](#scalability)
16+
- [Alternatives (Optional)](#alternatives-optional)
17+
<!-- /toc -->
18+
19+
## Summary
20+
21+
To ensure 1 to 1 mapping between a sandbox and a pod, we can let sandbox warmpool create sandboxes instead of only pods.
22+
23+
## Motivation
24+
25+
https://github.com/kubernetes-sigs/agent-sandbox/pull/115 enabled sandboxes to get pods from a warmpool instead of trying to starting up pods by themselves, which drastically reduced the latency for sandboxes to get ready. However it introduced a side effect. Before warmpool, a sandbox's pod would always have the same name as the sandbox; after warmpool, a sandbox's pod name would be diffrent from the sandbox's name if the sandbox adopted a pod from a warmpool. This makes it hard to keep track of what pods are owned by a sandbox, reducing the system's maintainability and readbility. For example, if a sandbox adopted several pods due to a bug in the sytem, we might not even notice it because the sandbox only keeps reference to one pod in its annotation.
26+
27+
## Proposal
28+
29+
Instead of letting sandbox warmpool create pods to be later adopted by sandboxes, we can directly create sandboxes with pods. This way we can make the sandbox and its pod use the same name. As a result, a sandbox's pod would always have the same name as the sandbox, presenting a consistent behavior no matter if a sandbox is cold-started or adopted from a warmpool.
30+
31+
### High-Level Design
32+
33+
Currently sandbox warmpool controller extracts the pod spec from the sandbox template. Since the sandbox template has information for the sandbox too, we can use the sandbox template to create the sandboxes.
34+
35+
When a sandbox claim is created, the sandbox claim controller can try to adopt a sandbox directly, instead of creating a sandbox first, then trying to adopt a pod from the warmpool.
36+
37+
The rest of the logic should remain unaffected, except the code in sandbox controller can be simplified since the controller reference and label setting can be done when the sandbox warmpool is creating sandboxes.
38+
39+
#### API Changes
40+
41+
No change needed.
42+
43+
#### Implementation Guidance
44+
45+
[createPoolPod](https://github.com/kubernetes-sigs/agent-sandbox/blob/2332dd153221cbb9299184432ed4a363bdd190c7/extensions/controllers/sandboxwarmpool_controller.go#L203) now should be `createPoolSandbox`, which not only creates a pod, but also a sandbox.
46+
47+
[createSandbox](https://github.com/kubernetes-sigs/agent-sandbox/blob/2332dd153221cbb9299184432ed4a363bdd190c7/extensions/controllers/sandboxclaim_controller.go#L242) now should try to adopt a sandbox from sandbox warm pool before creating a sandbox.
48+
49+
## Scalability
50+
51+
Since a sandbox CR is light and mapped to a pod, the change doesn't affect scalability of the system.
52+
53+
## Alternatives (Optional)
54+
55+
We could keep the sandbox warm pool's current design to produce pods. In sandbox claim controller, we could also create sandboxes of the same name as the adopted pod. This would also ensure the sandbox's name is always the same as its pod's name. It requires less code change, but is also less intuitive since the name "sandboxwarmpool" seems to indicate that it's a pool for sandboxes instead of pods.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
title: KEP Template
2+
kep-number: 127
3+
authors:
4+
- "@peterzhongyi"
5+
status: implementable
6+
creation-date: 2025-11-14
7+
reviewers:
8+
- "@barney-s"
9+
approvers:
10+
- "@janetkuo"
11+
12+
see-also:
13+
replaces:

0 commit comments

Comments
 (0)