-
Notifications
You must be signed in to change notification settings - Fork 110
Initial push for quickstart example #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for agent-sandbox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @alex-akv. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
examples/quickstart/README.md
Outdated
| @@ -0,0 +1,875 @@ | |||
| # Agent Sandbox Quickstart | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this to Secure Agent Sandbox Quickstart.
We also have a #220 simple example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in commit: 979e6a3
| - **Python SDK**: Programmatic sandbox management | ||
| - **Router Service**: HTTP proxy for SDK communication | ||
|
|
||
| --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a separate file instead of being inline here ?
Is there a reason there is a file separator here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we don't need separator there. I have removed it in the commit: 979e6a3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a large file. Would it make sense to split it into 3. The first file acting as a index for
- gVisor on KIND << separate file for this
2 Kata Containers on minikube << and this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split into 3 files in commit: 9502c20
examples/quickstart/README.md
Outdated
|
|
||
| **Continue to "Common Setup Steps" below** | ||
|
|
||
| --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same Q about yaml file separator. If this is meant for a doc-processor, would it work with multiple files instead of a single file separated by this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need separator there. Addressed it in commit: 979e6a3
|
if possible can we split it into 3 files ?
|
barney-s
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this detailed quickstart! It provides a clear path for users to try out the Agent Sandbox.
My review focuses on:
- Robustness: Improving the shell commands and Python script to handle edge cases and race conditions.
- Safety: Reducing the risk of aggressive commands like
pkillandrmaffecting the user's environment. - Maintainability: Avoiding hardcoded version numbers and ensuring instructions don't rot quickly.
examples/quickstart/README.md
Outdated
| - KIND (0.20+) | ||
| - Python 3.9+ | ||
| - Git | ||
| - Linux host (gVisor requires Linux) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wget is used in the installation steps but not listed in the prerequisites. Consider adding it or offering a curl alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it as prerequisite in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| ${URL}/containerd-shim-runsc-v1 ${URL}/containerd-shim-runsc-v1.sha512 | ||
| sha512sum -c runsc.sha512 \ | ||
| -c containerd-shim-runsc-v1.sha512 | ||
| rm -f *.sha512 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm -f *.sha512 in the current directory is risky if the user runs this in a directory with other files. Suggest creating a temporary directory for downloads or being more specific with the removal pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifed the solution to remove files explicitly in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| -c containerd-shim-runsc-v1.sha512 | ||
| rm -f *.sha512 | ||
| chmod a+rx runsc containerd-shim-runsc-v1 | ||
| sudo mv runsc containerd-shim-runsc-v1 /usr/local/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script uses sudo to move binaries. It's good practice to warn the user that root privileges will be required for this step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explained that root privs are required on top of the step in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| Configure the KIND cluster's containerd to support the gVisor runtime: | ||
|
|
||
| ```bash | ||
| docker exec -it agent-sandbox-demo-control-plane bash -c 'cat <<EOF > /etc/containerd/config.toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overwriting /etc/containerd/config.toml completely using cat > can break existing KIND configurations (e.g., registry mirrors). While acceptable for a demo, a warning or a sed based approach would be safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a warning in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| # Start minikube with containerd runtime | ||
| minikube start \ | ||
| --driver=kvm2 \ | ||
| --container-runtime=containerd \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8192MB (8GB) of RAM is a significant requirement for a quickstart. If Kata requires this much, please highlight this hard requirement in the prerequisites section so users don't fail halfway through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added requirements and explanation in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| ```bash | ||
| # Check router pods | ||
| kubectl get pods -l app=sandbox-router | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkill -f "port-forward ..." is quite aggressive and might terminate other unrelated port-forward sessions running on the user's machine. Consider tracking the specific PID or warning the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the approach in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| kubectl port-forward svc/sandbox-router-svc 8080:8080 & | ||
| sleep 2 | ||
| curl http://localhost:8080/healthz | ||
| # Should return: {"status":"ok"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating the venv in ~/agent-sandbox-venv modifies the user's home directory structure. Standard practice is often to create it in the current directory (e.g., python3 -m venv .venv) or let the user decide the location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the approach in commit: 7a6ea0d
|
|
||
| def setup_portforward(): | ||
| global portforward_proc, local_port | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.sleep(3) is brittle. It would be better to read the stdout of the portforward_proc process and wait for the "Forwarding from" line to confirm the tunnel is ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| sandboxTemplateRef: | ||
| name: python-runtime-template | ||
| EOF | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chmod +x is redundant here since the next instruction runs the script explicitly with python3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the chmod in commit: 7a6ea0d
examples/quickstart/README.md
Outdated
| kubectl apply -f - <<EOF | ||
| apiVersion: extensions.agents.x-k8s.io/v1alpha1 | ||
| kind: SandboxTemplate | ||
| metadata: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guide assumes the default namespace everywhere. While fine for a quickstart, explicitly creating a dedicated namespace (e.g., agent-sandbox-demo) makes cleanup easier (just delete the namespace) and avoids cluttering default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched from using default to agent-sandbox-demo dedicated namespace and modified cleanup steps in commit: 7a6ea0d
|
/lgtm |
|
|
||
| ```bash | ||
| git clone https://github.com/kubernetes-sigs/agent-sandbox.git | ||
| cd agent-sandbox/examples/python-runtime-sandbox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users can use prebuilt staging images to avoid the need to build images locally.
us-central1-docker.pkg.dev/k8s-staging-images/python-runtime-sandbox
us-central1-docker.pkg.dev/k8s-staging-images/sandbox-router
| - `gvisor` if you're using **gVisor on KIND** | ||
| - `kata-qemu` if you're using **Kata Containers on minikube** | ||
|
|
||
| ```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please turn this into an env var
| ```bash | |
| ```bash | |
| # Set the runtime based on your choice | |
| export RUNTIME_CLASS_NAME=gvisor # or 'kata-qemu' | |
| labels: | ||
| sandbox: python-sandbox | ||
| spec: | ||
| runtimeClassName: <RUNTIME_CLASS_NAME> # Replace with 'gvisor' or 'kata-qemu' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| runtimeClassName: <RUNTIME_CLASS_NAME> # Replace with 'gvisor' or 'kata-qemu' | |
| runtimeClassName: ${RUNTIME_CLASS_NAME} |
| ```bash | ||
| # WARNING: This overwrites the entire containerd config. | ||
| # If you have existing KIND configurations (e.g., registry mirrors), | ||
| # consider backing up /etc/containerd/config.toml first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While there's a warning, overwriting a system-critical file in a docker exec session is an anti-pattern for Kubernetes infrastructure automation. It can lead to NodeNotReady status if KIND-specific networking or mirror configurations are lost. Instead of a manual docker exec and systemctl restart, use the KIND-native way to configure runtimes during cluster creation, via containerdConfigPatches in the initial KIND cluster configuration file.
| ( | ||
| set -e | ||
| ARCH=$(uname -m) | ||
| URL=https://storage.googleapis.com/gvisor/releases/release/latest/${ARCH} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to pin to a specific version for a reproducible quickstart
| import threading | ||
| def read_output(): | ||
| for line in portforward_proc.stdout: | ||
| if "Forwarding from" in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no mechanism to stop the loop if the process fails to start or outputs an error. This could lead to orphaned threads if the port-forward fails.
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] | ||
| runtime_type = "io.containerd.runc.v2" | ||
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runsc] | ||
| runtime_type = "io.containerd.runsc.v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is runsc.v1 specified, instead of shim-v2?
| Cleaning up port-forward... | ||
| ``` | ||
|
|
||
| **Note:** Test 4 is optional and may occasionally fail if port-forward becomes unstable. Tests 1-3 are the critical validations - they prove WarmPool and SDK work correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test 4 waits for the tunnel to be ready. Does this note need to be updated?
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: alex-akv The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This quickstart example includes setting up Agent Sandbox with Warmpool and Python SDK using one of the two isolation strategies (gVisor on KIND | Kata Containers on minikube).