Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SANDBOX_PLURAL_NAME = "sandboxes"

POD_NAME_ANNOTATION = "agents.x-k8s.io/pod-name"
PODSNAPSHOT_POD_NAME_LABEL = "podsnapshot.gke.io/pod-name"

PODSNAPSHOT_API_GROUP = "podsnapshot.gke.io"
PODSNAPSHOT_API_VERSION = "v1alpha1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Agentic Sandbox Pod Snapshot Extension

This directory contains the Python client extension for interacting with the Agentic Sandbox to manage Pod Snapshots. This extension allows you to trigger snapshots of a running sandbox and restore a new sandbox from the recently created snapshot.
This directory contains the Python client extension for interacting with the Agentic Sandbox to manage Pod Snapshots. This extension allows you to trigger snapshots of a running sandbox and restore a new sandbox from a recently created snapshot.

## Components

Expand All @@ -14,10 +14,11 @@ This class wraps the base `Sandbox` to seamlessly provide snapshot capabilities.

### `SnapshotEngine`
The core engine responsible for interacting with the GKE Pod Snapshot Controller.
* Creates `PodSnapshotManualTrigger` custom resources.
* Watches for the snapshot controller to process the trigger and create a `PodSnapshot` resource.
* Returns a structured `SnapshotResponse` containing the success status, error details, and `snapshot_uid`.
* Ensures that manual trigger resources are cleanly deleted when the sandbox context exits.
* **Create**: Creates `PodSnapshotManualTrigger` custom resources and waits for the snapshot to be completed.
* **List**: Lists existing snapshots for a sandbox, with optional filtering by grouping labels and a flag to return ready-only snapshots.
* **Delete**: Deletes a specific snapshot by UID.
* **Delete All**: Deletes snapshots based on a strategy: either all snapshots for the pod, or filtered by grouping labels.
* **Cleanup**: Ensures that manual trigger resources are cleanly deleted when the sandbox context exits.

## Usage Example

Expand Down Expand Up @@ -59,7 +60,7 @@ This file, located in the parent directory (`clients/python/agentic-sandbox-clie
* Takes a snapshot (`test-snapshot-20`) after ~20 seconds.
2. **Phase 2: Restoring from Recent Snapshot**:
* Restores a sandbox from the second snapshot.
* Verifies that sandbox has been restored from the recent snapshot.
* Verifies that the sandbox has been restored from the recent snapshot.

### Prerequisites

Expand All @@ -79,7 +80,7 @@ This file, located in the parent directory (`clients/python/agentic-sandbox-clie
* For detailed setup instructions, refer to the [GKE Pod Snapshots public documentation](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/pod-snapshots).
* Ensure a GCS bucket is configured to store the pod snapshot states and that the necessary IAM permissions are applied.

4. **CRDs**: `PodSnapshotStorageConfig`, `PodSnapshotPolicy` CRDs must be applied. `PodSnapshotPolicy` should specify the selector match labels.
4. **CRDs**: `PodSnapshotStorageConfig`, `PodSnapshotPolicy` CRDs must be applied. `PodSnapshotPolicy` should specify the selector match labels. (Note: For the test file to work, `maxSnapshotCountPerGroup` in `PodSnapshotPolicy` must be set to 2 or more, and the grouping labels must include `tenant-id` and `user-id`.)

5. **Sandbox Template**: A `SandboxTemplate` (e.g., `python-counter-template`) with runtime gVisor, appropriate KSA and label that matches that selector label in `PodSnapshotPolicy` must be available in the cluster.

Expand Down
Loading