Create Your First Sandbox
This guide creates a Python Sandbox, waits for it to become Ready, executes a command, suspends and resumes it, and then deletes it.
TOC
Before You BeginCreate a Namespace and Expiration TimeCreate the SandboxWait for ReadyRun a CommandSuspend and ResumeDelete the SandboxBefore You Begin
- Install and verify Agent Sandbox
v0.5.4-1. - Connect
kubectlto the target workload cluster, not the global cluster. - Ensure the workload cluster can pull
docker-mirrors.alauda.cn/library/python:3.12-alpine. - Install Python 3 locally to generate a future RFC3339 expiration timestamp.
Verify the active cluster before applying or deleting any resource:
Continue only when the output is the intended workload cluster.
Create a Namespace and Expiration Time
Set the namespace and create an expiration time 30 minutes in the future:
shutdownTime is an absolute RFC3339 timestamp. It is not an idle timeout and is not automatically extended by commands or network activity.
Create the Sandbox
Apply a v1beta1 Sandbox with a restricted-compatible security context:
The controller manages a Pod named python-sandbox in the same namespace.
Wait for Ready
Wait for the Sandbox Ready condition and inspect the resources:
If the wait times out, inspect the Sandbox, Pod, events, and controller logs before continuing.
Run a Command
Execute Python in the Sandbox container:
Expected output includes:
Suspend and Resume
Suspend the Sandbox:
Resume it and wait for Ready again:
In v0.5.4, the Suspended condition remains present while the Sandbox is running. Clients must inspect its boolean status instead of using condition presence as the state check.
Delete the Sandbox
Verify the active context and $BUSINESS_NAMESPACE before deleting the resource.
Delete the Sandbox when the exercise is complete:
Because this example uses shutdownPolicy: Delete, the controller also deletes the Sandbox when shutdownTime is reached. Do not delete the CRD as part of ordinary workload cleanup.