Documentation for Kubernetes Agent Sandbox - a CRD-based system for managing isolated AI agent execution environments...
AIエージェントのための、Kubernetes上の分離された実行環境を管理するCRDとコントローラー。
リポジトリ: https://github.com/kubernetes-sigs/agent-sandbox
Core (agents.x-k8s.io)
└─ Sandbox → Pod, Service, PVC管理
Extensions (extensions.agents.x-k8s.io)
├─ SandboxTemplate → テンプレート + NetworkPolicy
├─ SandboxClaim → テンプレートから作成
└─ SandboxWarmPool → プール管理
Client: Python SDK → Sandbox Router → Sandbox Pod
詳細: ./references/README.md
目的: 単一ステートフルPod + Service + PVC管理
主要Specフィールド:
podTemplate.spec (必須) - Pod仕様volumeClaimTemplates - PVCテンプレートshutdownTime - 自動削除時刻 (RFC 3339)replicas - 0または1Statusフィールド: serviceFQDN, service, conditions, replicas
検索:
grep -A 15 "## Spec フィールド" ./references/CRDs/Sandbox.md
grep -A 15 "## 最小構成例" ./references/CRDs/Sandbox.md
詳細: ./references/CRDs/Sandbox.md
目的: 再利用可能テンプレート + NetworkPolicy
主要Specフィールド:
podTemplate (必須) - Pod定義networkPolicy.ingress - IngressルールnetworkPolicy.egress - Egressルールセキュア構成例:
spec:
podTemplate:
spec:
runtimeClassName: gvisor
networkPolicy:
egress:
- ports:
- protocol: UDP
port: 53 # DNS のみ
検索:
grep -A 40 "## セキュアな設定例" ./references/CRDs/SandboxTemplate.md
詳細: ./references/CRDs/SandboxTemplate.md
目的: SandboxTemplateからSandbox作成要求
主要Specフィールド:
sandboxTemplateRef.name (必須) - SandboxTemplate名sandboxTemplateRef.namespace - namespaceStatusフィールド: sandboxName, conditions
Python SDK統合: SandboxClientが内部的に使用
検索:
grep -A 20 "## 動作フロー" ./references/CRDs/SandboxClaim.md
詳細: ./references/CRDs/SandboxClaim.md
目的: Sandboxプール (コールドスタート削減)
主要Specフィールド:
replicas (必須) - プール内Sandbox数sandboxTemplateRef.name (必須) - SandboxTemplate名Statusフィールド: replicas, readyReplicas, conditions
検索:
grep -A 20 "## HPA" ./references/CRDs/SandboxWarmPool.md
詳細: ./references/CRDs/SandboxWarmPool.md
pip install "git+https://github.com/kubernetes-sigs/agent-sandbox.git@main#subdirectory=clients/python/agentic-sandbox-client"
コンストラクタ主要パラメータ:
| パラメータ | 型 | デフォルト | 説明 |
|---|---|---|---|
template_name |
str | (必須) | SandboxTemplate名 |
namespace |
str | "default" | namespace |
gateway_name |
str | None | None | Gateway名 (Production) |
api_url |
str | None | None | 直接URL (Direct) |
server_port |
int | 8888 | Sandboxサーバーポート |
コアメソッド:
| メソッド | 戻り値 | 説明 |
|---|---|---|
run(command, timeout=60) |
ExecutionResult |
コマンド実行 |
write(path, content, ...) |
None | ファイル書き込み |
read(path, timeout=60) |
bytes | ファイル読み込み |
is_ready() |
bool | 接続確認 |
接続モード:
使用例:
from agentic_sandbox import SandboxClient
with SandboxClient(template_name="python-sandbox-template") as sandbox:
result = sandbox.run("python -c 'print(42)'")
print(result.stdout) # "42\n"
sandbox.write("/tmp/test.py", "print('Hello')")
result = sandbox.run("python /tmp/test.py")
検索:
grep -A 15 "^```python" ./references/python-sdk/SandboxClient.md
grep -A 30 "## 内部動作" ./references/python-sdk/SandboxClient.md
詳細: ./references/python-sdk/SandboxClient.md
目的: X-Sandbox-IDヘッダーベース動的ルーティングプロキシ
詳細: ./references/python-sdk/SandboxRouter.md
目的: Gemini Computer Use統合 (agent(query: str)メソッド)
詳細: ./references/python-sdk/ComputerUseExtension.md
場所: ./references/examples/
| 例 | 難易度 | ユースケース | ファイル |
|---|---|---|---|
| python-runtime-sandbox | ⭐ | 基本コマンド実行API | ./references/examples/python-runtime-sandbox.md |
| aio-sandbox | ⭐ | All-in-One (VNC, VSCode, Jupyter) | ./references/examples/aio-sandbox.md |
| gemini-cu-sandbox | ⭐⭐ | Gemini Computer Use (ブラウザ) | ./references/examples/gemini-cu-sandbox.md |
| vscode-sandbox | ⭐⭐ | VSCode + gVisor/Kata分離 | ./references/examples/vscode-sandbox.md |
最小FastAPI実装。/execute, /upload, /download エンドポイント。カスタムランタイムの出発点。
VNC, VSCode Server, Jupyter統合環境。agent-infra/sandbox ベース。
Gemini Computer Use。/agent エンドポイントで自然言語タスク実行。要: Gemini API keySecret。
VSCode Server + gVisor/Kata。Sandbox Router経由アクセス。
検索:
grep -A 10 "## API" ./references/examples/<example-name>.md
grep -A 20 "## マニフェスト" ./references/examples/<example-name>.md
→ SandboxTemplate + gVisor + NetworkPolicy (DNS egress のみ)
grep -A 40 "## セキュアな設定例" ./references/CRDs/SandboxTemplate.md
→ CRD Reference Map参照、または:
grep -A 20 "## Spec フィールド" ./references/CRDs/<CRD名>.md
→ SandboxClient(template_name="...") 使用 (上記Python SDK参照)
→ Implementation Examples Index参照
ls ./references/examples/*.md
→ ingress/egress定義 (デフォルト全拒否)
grep -A 10 "### NetworkPolicySpec" ./references/CRDs/SandboxTemplate.md
skills/references/
├── README.md # プロジェクト概要 (94行)
├── CRDs/
│ ├── README.md # CRD一覧 (63行)
│ ├── Sandbox.md # (101行)
│ ├── SandboxTemplate.md # (122行)
│ ├── SandboxClaim.md # (75行)
│ └── SandboxWarmPool.md # (97行)
├── python-sdk/
│ ├── README.md # (23行)
│ ├── SandboxClient.md # (161行)
│ ├── SandboxRouter.md # (57行)
│ └── ComputerUseExtension.md # (51行)
└── examples/
├── README.md # (50行)
├── python-runtime-sandbox.md # (76行)
├── aio-sandbox.md # (87行)
├── gemini-cu-sandbox.md # (102行)
└── vscode-sandbox.md # (82行)
合計: 16ファイル、~1,147行
Tier 1 (最頻):
./references/python-sdk/SandboxClient.md./references/CRDs/Sandbox.md./references/CRDs/SandboxTemplate.mdTier 2 (コンテキスト):
./references/README.md./references/examples/python-runtime-sandbox.mdTier 3 (オンデマンド): その他
ローカル不十分時:
CodeWiki: https://codewiki.google/github.com/kubernetes-sigs/agent-sandbox
使用時:
# 全CRDのSpecフィールド
grep -A 15 "## Spec フィールド" ./references/CRDs/*.md
# YAML例検索
grep -n "^```yaml" ./references/CRDs/<file>.md
# NetworkPolicy
grep -A 30 "networkPolicy" ./references/CRDs/SandboxTemplate.md
# Python例
grep -A 15 "^```python" ./references/python-sdk/*.md
# 全体検索
grep -r "keyword" ./references/
## 統一v1alpha1