Skip to content
k8s-agent-sandbox logo

Kubernetes Agent Sandbox

k8s-agent-sandbox

Documentation for Kubernetes Agent Sandbox - a CRD-based system for managing isolated AI agent execution environments. Use for queries about Sandbox CRDs (Sandbox, SandboxTemplate, SandboxClaim, SandboxWarmPool), Python SDK (SandboxClient, SandboxRouter, ComputerUseExtension), network policies, s...

SKILL.md

Full skill instructions

Kubernetes Agent Sandbox

AIエージェントのための、Kubernetes上の分離された実行環境を管理するCRDとコントローラー。

リポジトリ: https://github.com/kubernetes-sigs/agent-sandbox

主な機能

  • Sandbox (Core): ステートフルPodのライフサイクル管理
  • 拡張機能: SandboxTemplate (テンプレート), SandboxClaim (オンデマンド作成), SandboxWarmPool (プリウォーム)
  • Python SDK: Kubernetes上のSandboxと対話するクライアント
  • NetworkPolicy統合: ネットワーク分離によるセキュア実行環境

アーキテクチャ概要

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


CRD Reference Map

Sandbox (agents.x-k8s.io/​v1alpha1)

目的: 単一ステートフルPod + Service + PVC管理

主要Specフィールド:

  • podTemplate.spec (必須) - Pod仕様
  • volumeClaimTemplates - PVCテンプレート
  • shutdownTime - 自動削除時刻 (RFC 3339)
  • replicas - 0または1

Statusフィールド: serviceFQDN, service, conditions, replicas

検索:

grep -A 15 "## Spec フィールド" ./​references/​CRDs/​Sandbox.md
grep -A 15 "## 最小構成例" ./​references/​CRDs/​Sandbox.md

詳細: ./​references/​CRDs/​Sandbox.md


SandboxTemplate (extensions.agents.x-k8s.io/​v1alpha1)

目的: 再利用可能テンプレート + 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


SandboxClaim (extensions.agents.x-k8s.io/​v1alpha1)

目的: SandboxTemplateからSandbox作成要求

主要Specフィールド:

  • sandboxTemplateRef.name (必須) - SandboxTemplate名
  • sandboxTemplateRef.namespace - namespace

Statusフィールド: sandboxName, conditions

Python SDK統合: SandboxClientが内部的に使用

検索:

grep -A 20 "## 動作フロー" ./​references/​CRDs/​SandboxClaim.md

詳細: ./​references/​CRDs/​SandboxClaim.md


SandboxWarmPool (extensions.agents.x-k8s.io/​v1alpha1)

目的: Sandboxプール (コールドスタート削減)

主要Specフィールド:

  • replicas (必須) - プール内Sandbox数
  • sandboxTemplateRef.name (必須) - SandboxTemplate名

Statusフィールド: replicas, readyReplicas, conditions

検索:

grep -A 20 "## HPA" ./​references/​CRDs/​SandboxWarmPool.md

詳細: ./​references/​CRDs/​SandboxWarmPool.md


Python SDK Reference

インストール

pip install "git+https://github.com/​kubernetes-sigs/​agent-sandbox.git@main#subdirectory=clients/​python/​agentic-sandbox-client"

SandboxClient

コンストラクタ主要パラメータ:

パラメータ型デフォルト説明
template_namestr(必須)SandboxTemplate名
namespacestr"default"namespace
gateway_namestr | NoneNoneGateway名 (Production)
api_urlstr | NoneNone直接URL (Direct)
server_portint8888Sandboxサーバーポート

コアメソッド:

メソッド戻り値説明
run(command, timeout=60)ExecutionResultコマンド実行
write(path, content, ...)Noneファイル書き込み
read(path, timeout=60)bytesファイル読み込み
is_ready()bool接続確認

接続モード:

  • Tunnel (デフォルト): kubectl port-forward - ローカル開発用
  • Gateway: gateway_name指定 - 本番環境用
  • Direct: api_url指定 - クラスタ内部用

使用例:

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


SandboxRouter

目的: X-Sandbox-IDヘッダーベース動的ルーティングプロキシ

詳細: ./​references/​python-sdk/​SandboxRouter.md

ComputerUseExtension

目的: Gemini Computer Use統合 (agent(query: str)メソッド)

詳細: ./​references/​python-sdk/​ComputerUseExtension.md


Implementation Examples Index

場所: ./​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

python-runtime-sandbox (⭐)

最小FastAPI実装。/​execute, /​upload, /​download エンドポイント。カスタムランタイムの出発点。

aio-sandbox (⭐)

VNC, VSCode Server, Jupyter統合環境。agent-infra/​sandbox ベース。

gemini-cu-sandbox (⭐⭐)

Gemini Computer Use。/​agent エンドポイントで自然言語タスク実行。要: Gemini API keySecret。

vscode-sandbox (⭐⭐)

VSCode Server + gVisor/​Kata。Sandbox Router経由アクセス。

検索:

grep -A 10 "## API" ./​references/​examples/<example-name>.md
grep -A 20 "## マニフェスト" ./​references/​examples/<example-name>.md

Common Query Patterns

"セキュアなSandboxを作成するには?"

→ SandboxTemplate + gVisor + NetworkPolicy (DNS egress のみ)

grep -A 40 "## セキュアな設定例" ./​references/​CRDs/​SandboxTemplate.md

"[CRD名] のフィールドは?"

→ CRD Reference Map参照、または:

grep -A 20 "## Spec フィールド" ./​references/​CRDs/<CRD名>.md

"Sandboxに接続するには?"

→ SandboxClient(template_name="...") 使用 (上記Python SDK参照)

"特定ランタイム実装は?"

→ Implementation Examples Index参照

ls ./​references/​examples/​*.md

"NetworkPolicy設定は?"

→ ingress/​egress定義 (デフォルト全拒否)

grep -A 10 "### NetworkPolicySpec" ./​references/​CRDs/​SandboxTemplate.md

How to Use This Skill

ファイル構成

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行

検索戦略

API/フィールドクエリ

  1. SKILL.mdのCRD Reference Map確認
  2. grepで詳細抽出
  3. 必要なら完全ファイル読み込み

実装ガイダンス

  1. Common Query Patterns確認
  2. Implementation Examples Index参照
  3. 該当例ファイル読み込み

SDK使用方法

  1. Python SDK Reference確認
  2. 基本用法はSKILL.mdで完結
  3. 高度な用法はgrepまたはファイル読み込み

優先度

Tier 1 (最頻):

  • ./​references/​python-sdk/​SandboxClient.md
  • ./​references/​CRDs/​Sandbox.md
  • ./​references/​CRDs/​SandboxTemplate.md

Tier 2 (コンテキスト):

  • ./​references/​README.md
  • ./​references/​examples/​python-runtime-sandbox.md

Tier 3 (オンデマンド): その他

Web フォールバック

ローカル不十分時:

CodeWiki: https://codewiki.google/​github.com/​kubernetes-sigs/​agent-sandbox

使用時:

  • references/に無い実装詳細
  • 最新変更/アップデート
  • 高度なトラブルシューティング
  • Controller実装詳細

便利なgrep パターン

# 全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/

言語注記

  • ドキュメント: 日本語
  • grepキーワード: 日本語 (例: "フィールド", "設定例")
  • セクションヘッダー: ## 統一
  • コード例: 言語非依存

バージョン

  • CRD: v1alpha1
  • 更新: 2025-12-21
  • ソース: kubernetes-sigs/​agent-sandbox (main)

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View