Create an Agent Sandbox Container Edition

Updated at:

You can create an Agent Sandbox Container Edition (sandbox) in an ACS cluster by installing the required add-ons, creating a warm pool, integrating an SDK, and configuring a domain name and certificate for a production environment.

Preparations

  1. Create an ACS cluster, and activate the Agent Sandbox Container Edition Service.

  2. If you already have a cluster, you must also upgrade the following to the required versions after you activate the service.

    1. Upgrade the acs-virtual-node add-on to v2.17.0 or later.

    2. Upgrade the Kube Scheduler component.

      Cluster version

      Kube Scheduler component version

      v1.28

      v1.28.12-aliyun-1.4.6 or later

      v1.30

      v1.30.3-aliyun-1.6.2 or later

      v1.31

      v1.31.0-aliyun-1.5.2 or later

      v1.32

      v1.32.0-apsara.6.11.11.3187ac8f or later

Install add-ons

Note

If the add-ons are already installed, upgrade the ack-agent-sandbox-controller add-on to v0.5.14-release.1 or later, and upgrade the ack-sandbox-manager add-on to v0.6.0 or later.

  1. Log on to the ACS console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Add-ons.

  3. Install the ack-agent-sandbox-controller add-on.

    When you install this component for the first time, you must grant the AliyunCSManagedAgentSandboxRole role permissions to access your cloud resources. You can use the default parameter settings. If you require higher concurrency, you can increase the resource specifications.

    For more information about the features of this add-on, see ack-agent-sandbox-controller.

  4. Install an Ingress controller add-on.

    1. Install any Ingress controller add-on supported by ACS to access the sandbox-manager Service from outside the cluster. The following steps create an Internet-facing ALB instance as described in Install the ALB Ingress Controller.

    2. Prepare an E2B domain name. For more information about how to prepare a domain name, configure DNS resolution, and apply for a certificate, see Configure a domain name and certificate.

    3. If you use ALB Ingress Controller, you must also add an HTTPS:443 listener configuration to both the ALB instance and the Ingress.

      Update AlbConfig and add an HTTPS:443 listener to the ALB instance.

      1. In the left-side navigation pane, choose Workloads > Custom Resources. On the Resource Objects tab, search for AlbConfig, and then click the search result.

      2. In the list of AlbConfig resource objects, find the target resource alb, and in the Actions column on the right, click Edit YAML.

      3. Add the spec.listeners.port: 443 and spec.listeners.protocol: HTTPS fields, and then click OK.

        spec:
          config:
            addressAllocatedMode: Fixed
            addressType: Internet
            zoneMappings:
              - vSwitchId: vsw-xxx
              - vSwitchId: vsw-xxx
          listeners:
            - port: 80
              protocol: HTTP
            - port: 443
              protocol: HTTPS

      Update the Ingress to associate the HTTPS:443 listener.

      1. In the left-side navigation pane, choose Network > Ingresses. For the sandbox-manager Ingress, in the Actions column on the right, click Update.

      2. Add the following configuration and click OK.

        • Annotations: alb.ingress.kubernetes.io/listen-ports: [{"HTTP": 80}, {"HTTPS": 443}]

  1. Install the ack-sandbox-manager add-on.

    1. Configure the add-on parameters.

      Set className to alb (the IngressClass created by the Ingress controller that you installed in the previous step), set domain to your actual domain name, and set adminApiKey to a custom API key. Keep the other settings at their default values. After the add-on is installed, an Ingress is created in the sandbox-system namespace with the name sandbox-manager.

      Detailed parameter description

      Section

      Parameter

      Description

      sandboxManager

      replicaCount

      The number of sandbox-manager instances. Default value: 3.

      E2B

      domain

      The E2B domain name. For more information, see Configure a domain name and certificate.

      Enable E2B_API_KEY verification

      Specifies whether to enable API_KEY authentication. Authentication is enabled by default.

      adminApiKey

      After authentication is enabled, this parameter specifies the initial key during the first installation. Replace it with a custom API key.

      Controller

      logLevel

      The log level of the controller. Default value: 1.

      resources.requests.cpu

      The CPU request of the controller. Default value: 2.

      resources.requests.memory

      The memory request of the controller. Default value: 4Gi.

      Proxy

      resources.requests.cpu

      The CPU request of the proxy. Default value: 2.

      resources.requests.memory

      The memory request of the proxy. Default value: 4Gi.

      Ingress

      className

      The name of an IngressClass that is already configured in the cluster, such as alb or mse.

      Important
      1. SDKs later than E2B v2.25 impose a format requirement on API_KEY. We recommend that you set it to a value that matches the following regular expression: e2b_[0-9a-f]+

      2. The E2B admin key is mainly used to create and manage other keys and has extensive permissions. Keep it secure. We recommend that you follow the Multi-tenancy management documentation to create a regular key for daily sandbox operations.

Create an Agent Sandbox Container Edition

Step 1: Create a warm pool by using SandboxSet

A warm pool is a set of pre-created Sandbox replicas managed by the SandboxSet CR. Applications obtain ready Sandboxes directly from the warm pool, which significantly improves delivery efficiency.
  1. In the left-side navigation pane, click Custom Resources, choose the CRDs tab, and then click Create from YAML.

  2. Use the following YAML to create a SandboxSet resource. ack-sandbox-manager automatically watches and identifies the resource, and initializes a sandbox template configuration named code-interpreter at the same time.

    apiVersion: agents.kruise.io/v1alpha1
    kind: SandboxSet
    metadata:
      name: code-interpreter
      namespace: default
    spec:
      runtimes:
      - name: csi           # Supports CSI mounting. Newly created Sandboxes are injected with the corresponding Sidecar
      - name: agent-runtime # Injects environment management tools such as envd
      replicas: 4
      template:
        metadata:
          labels:
            alibabacloud.com/acs: "true"
            alibabacloud.com/compute-class: agent-sandbox # Agent Sandbox instance type 
            alibabacloud.com/compute-qos: default # Compute QoS: default
        spec:
          automountServiceAccountToken: false
          containers:
          - image: registry-cn-zhangjiakou-vpc.ack.aliyuncs.com/acs/code-interpreter:v1.6 # Replace with the region where your cluster is deployed
            imagePullPolicy: IfNotPresent
            name: sandbox
            resources:
              limits:
                cpu: "1"
                memory: 1Gi
              requests:
                cpu: "1"
                memory: 1Gi
                ephemeral-storage: 30Gi
          terminationGracePeriodSeconds: 30

    For more information about the fields and advanced configurations of the SandboxSet CRD, see Sandbox CRD field descriptions.

    Important

    The code-interpreter image is intended only for verification in test environments. If you want to deploy it in a production environment, you must perform the necessary security hardening. Expand the section below to view the detailed image instructions.

    code-interpreter image usage instructions

    • Image pull: The registry-cn-zhangjiakou-vpc.ack.aliyuncs.com/acs/code-interpreter image is a sample image that ACS builds based on the e2b-code-interpreter project. It is compatible with the run_code operation of the E2B client. To speed up image pulls, you can change the region in the image address to your actual region name, or remove -vpc to pull the image over the Internet.

    • Use a custom image: If you want to use E2B code-interpreter (directly or as a base image), we recommend that you select a versioned image provided by ACS. ACS does not guarantee runtime compatibility with the official E2B latest image. If you need to use a custom image, make sure that the image meets the following conditions:

      1. It contains basic commands such as cp, mv, and mkdir.

      2. It contains bash, and the executable file is located at /bin/bash.

      When you use a custom image, the E2B run_code method is temporarily unavailable.

  3. In the left-side navigation pane, click Pods, select the corresponding namespace, and view the created code-interpreter Sandbox.

    You can run the kubectl get sbs command to view SandboxSet resources, where AVAILABLE indicates the number of Sandboxes that are ready.

After a Sandbox is allocated, SandboxSet automatically triggers the replenishment process to maintain the number of instances in the warm pool.

Step 2: Obtain an Agent Sandbox Container Edition

E2B SDK method

You can use the E2B SDK to develop and deploy projects and view the results on the platform, including running code (run_code), reading and writing files (files.write/files.read), and running commands (commands.run). For more information about how to use the SDK, see Connect to Agent Sandbox Container Edition by using the E2B SDK.

  1. Install Python in your local environment.

  2. Install the E2B Python SDK.

    pip install "e2b-code-interpreter" "e2b"
  3. Configure environment variables.

    # Uses the default domain name configured when you installed the ack-sandbox-manager add-on. Do not include *. You can modify it based on your actual configuration.
    export E2B_DOMAIN=your.domain.com
    # Uses the default API key configured when you installed the ack-sandbox-manager add-on. You can modify it based on your actual configuration.
    export E2B_API_KEY=e2b_abcdef
    # The path to the CA certificate that the client must trust, as used in the steps to configure the domain name and certificate
    export SSL_CERT_FILE=/path/to/ca-fullchain.pem
    Note

    Replace the value of the E2B_API_KEY variable with the value that you actually configured.

  4. Save the following code as the main.py file.

    # Import the E2B SDK
    from e2b_code_interpreter import Sandbox
    sbx: Sandbox = Sandbox.create(template="code-interpreter")
    print(f"sandbox id: {sbx.sandbox_id}")
    result = sbx.run_code("print('hello, world')")
    print(f"run code result: {result}")
    text = input("enter some text to be saved to file 'text.txt' inside sandbox:  ")
    sbx.files.write("text.txt", text)
    print(f"read file from sandbox via files api: [{sbx.files.read('text.txt')}]")
    print(f"read file from sandbox via commands api: [{sbx.commands.run('cat text.txt')}]")
    input("press ENTER to kill the sandbox")
    print(sbx.kill())
                                

    Description of the create operation metadata parameter

    For more information about how to use the metadata parameter of the create operation, see Usage examples.

    Key

    Description

    Value

    e2b.agents.kruise.io/never-timeout

    Specifies whether to configure an automatic cleanup time for the Sandbox. If you set this parameter to true, the Sandbox is not automatically cleaned up based on a timeout.

    • false

    • true

    e2b.agents.kruise.io/image

    Specifies whether to designate a runtime image for the requested Sandbox. If the image differs from the one declared in the warm pool, the image is updated in place.

    A specific image name, such as ghcr.io/openclaw/openclaw:****

    e2b.agents.kruise.io/wait-ready-timeout-seconds

    Used mainly in the image update scenario when a Sandbox is requested. Specifies the maximum amount of time to wait for the image update to complete.

    An integer. Default value: 60.

    e2b.agents.kruise.io/csi-volume-config

    Allows NAS or OSS to be dynamically mounted when a Sandbox is requested. The value is a JSON string that supports fine-grained configuration of multiple mount targets. Each mount target supports the following configurations:

    1. pvName: the name of the PersistentVolume of the aforementioned OSS or NAS.

    2. mountPath: the mount directory in the sandbox.

    3. subPath: the BucketPath of OSS or NAS, which indicates an absolute address.

    volume_config = [

    {"pvName": "oss-pv-sandbox-system", "mountPath": "/home/data-oss1", "subPath": "data-subPath1","readOnly": true}]

    e2b.agents.kruise.io/claim-timeout-seconds

    The maximum amount of time to wait to obtain an available sandbox. If this period is exceeded, the request is directly marked as failed.

    An integer. Default value: 60.

    e2b.agents.kruise.io/create-on-no-stock

    By default, a sandbox is always obtained from the warm pool. If no sandbox is available in the warm pool, the system waits for sandboxes to be replenished and become ready. If you configure this parameter, a sandbox can be created directly from the warm pool template, which reduces the waiting time.

    • false

    • true

    Default value: false

    e2b.agents.kruise.io/skip-init-runtime

    Specifies whether to skip the initialization of Agent-runtime in the Sandbox instance when the instance is requested. If no runtime process exists or you require a high degree of customization, you can set this parameter to true.

    • false

    • true

    Default value: true

    e2b.agents.kruise.io/reserve-failed-sandbox

    When an error occurs while a sandbox is being obtained, the sandbox manager directly cleans up the faulty sandbox. You can use this field to make the sandbox manager retain the Sandbox instance on which the error occurred for troubleshooting.

    • false

    • true

    Default value: false

    Custom metadata

    When you obtain a sandbox, you can add annotations to the Sandbox instance by using custom key-value pairs.

    A custom value, such as {"userId": "alice"}.

  5. Run the main.py file to create and verify the Sandbox.

    After the first prompt appears, enter text such as acs agent sandbox, and then press ENTER. In the Pod named code-interpreter-29***, the text is written to the /home/user/text.txt file: acs agent sandbox. If you press ENTER again, the current Sandbox is deleted.
    python main.py

    Expected output:

    sandbox id: default--code-interpreter-29***
    run code result: Execution(Results: [], Logs: Logs(stdout: ['hello, world\n'], stderr: []), Error: None)
    enter some text to be saved to file 'text.txt' inside sandbox:  acs agent sandbox
    read file from sandbox via files api: [acs agent sandbox]
    read file from sandbox via commands api: [CommandResult(stderr='', stdout='acs agent sandbox', exit_code=0, error='')]
    press ENTER to kill the sandbox
    True

SandboxClaim method

After the warm pool allocates a Sandbox, the automatic replenishment logic starts immediately to quickly backfill warm instances.

  1. In the left-side navigation pane, click Custom Resources, choose the CRDs tab, and then click Create from YAML.

  2. Use the following YAML to create a SandboxClaim resource to obtain a Sandbox.

    apiVersion: agents.kruise.io/v1alpha1
    kind: SandboxClaim
    metadata:
      name: code-interpreter              # SandboxSet name
      namespace: default                  # SandboxSet namespace
    spec:  
      templateName: code-interpreter      # Specifies the name of the SandboxSet
      replicas: 1                         # The number of sandboxes to obtain from the SandboxSet
      claimTimeout: 5m                    # Specifies the timeout period of the SandboxClaim 
      ttlAfterCompleted: 15m              # Specifies the TTL period after the SandboxClaim completes. After the task completes and the TTL period elapses, the SandboxClaim resource is deleted (the obtained sandbox is not deleted).
  3. In the left-side navigation pane, click Pods, select the default namespace, and view the newly obtained Sandbox named code-interpreter-xxxxx.

    You can run the kubectl get sbx -l agents.kruise.io/claim-name=code-interpreter command to obtain the Sandbox status.
Developers can also manage Sandbox resources by using the Kubernetes SDK.

Replace the Agent Sandbox Container Edition container image

E2B SDK method

Refer to the following Python code. Replace <YOUR_IMAGE> with the actual image address. After a Sandbox is taken from the warm pool, the metadata parameter is used to replace the container image with the specified image.

from e2b_code_interpreter import Sandbox
# timeout: the default duration is 300 seconds
sbx = Sandbox.create(template="some-template", timeout=300, metadata={
    # Replace the image of the sandbox container in place with the specified image
    "e2b.agents.kruise.io/image": "<YOUR_IMAGE>"
})
Note

Sandboxes support image caching (Image Cache) to accelerate image pulls. You can use the Annotation ops.alibabacloud.com/update-with-image-cache to control when the image cache is used. The valid values and applicable scenarios are as follows:

  • false (default): Uses the image cache when the warm pool scales out . In this mode, the image cache is not used for subsequent image updates. This mode applies to scenarios where the updated image shares many layers with the warm pool image and can be largely reused.

  • true: Uses the image cache during image updates. In this mode, the cache is not used when the warm pool scales out. This mode applies to scenarios where the warm pool uses a lightweight placeholder image, or where the target image for the update is large.

Expand to view the YAML example

apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
metadata:
  name: code-interpreter
spec:
  template:
    metadata:
      annotations:
        # Allows the image cache to be used during image updates. Default value: false
        ops.alibabacloud.com/update-with-image-cache: "true"
...

SandboxClaim method

Replace the following <YOUR_IMAGE> with the actual image address.

apiVersion: agents.kruise.io/v1alpha1
kind: SandboxClaim
metadata:
  name: my-sandbox-claim
  namespace: default
spec:
  templateName: code-interpreter    # Specifies the name of the SandboxSet warm pool
  replicas: 1
  claimTimeout: 5m
  ttlAfterCompleted: 15m
  inplaceUpdate:
    # The target image to update to
    image: <YOUR_IMAGE> # Replace with the actual image address

Specify the Agent Sandbox Container Edition resource specifications

In-place vertical scaling (VPA) is supported when a Sandbox is allocated from the warm pool. A pre-warmed sandbox instance with lower specifications can be upgraded to the specifications required by your workload without the Pod being rebuilt, which balances fast provisioning from the warm pool with the differentiated resource requirements of your workload.

Note
  • Only CPU adjustments are currently supported. Memory and other resources are ignored, and only the main container is adjusted. For more information about the limits and usage notes, see In-place vertical scaling for containers based on CPU metrics.

  • If the cluster version is earlier than 1.32, you must go to the Add-ons page and set the feature gate of Kube API Server to InPlacePodVerticalScaling=true to enable in-place resource resizing.

Step 1: Enable in-place resource resizing for SandboxSet

In the spec.template.metadata.annotations of the SandboxSet, add scaling.alibabacloud.com/enable-inplace-resource-resize: "true" to allow Sandboxes in the warm pool to perform in-place VPA when they are allocated.

The following example creates only a warm pool with smaller specifications. You can specify specifications to dynamically scale out during subsequent allocations.
apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
metadata:
  name: code-interpreter
spec:
  template:
    metadata:
      annotations:
        # When a Sandbox is allocated from the warm pool, allow in-place VPA
        scaling.alibabacloud.com/enable-inplace-resource-resize: "true"
    spec:
      containers:
        - name: interpreter
          image: xxx
          resources:
            requests:
              cpu: 500m     
              memory: 1Gi 
            limits:
              cpu: 500m 
              memory: 1Gi
  replicas: 5  # The number of warm instances

Step 2: Declare the target resource specifications during allocation

When you allocate an Agent Sandbox Container Edition from the warm pool, you can dynamically scale the CPU to the specified specifications in the following two ways:

E2B SDK method

In Sandbox.create, use the agreed keys in metadata to declare the target CPU specifications.

from e2b_code_interpreter import Sandbox
sbx = Sandbox.create(template="code-interpreter", metadata={
    "e2b.agents.kruise.io/cpu-request": "1000m",
    "e2b.agents.kruise.io/cpu-limit": "1000m"
})

SandboxClaim method

Declare the target resource specifications in the spec.inplaceUpdate.resources field of SandboxClaim.

apiVersion: agents.kruise.io/v1alpha1
kind: SandboxClaim
metadata:
  name: code-interpreter-vpa-claim
  namespace: default
spec:
  templateName: code-interpreter
  replicas: 1
  claimTimeout: 5m
  ttlAfterCompleted: 15m
  inplaceUpdate:  # Declare the target resource specifications
    resources:
      requests:
        cpu: 1000m
      limits:
        cpu: 1000m

Delete an Agent Sandbox Container Edition

To completely remove an instance, you can delete the sandbox in the following ways.

E2B SDK method

Delete a sandbox instance through the E2B SDK: replace the following <YOUR_SANDBOX_ID> with the actual sandbox id.

from e2b_code_interpreter import Sandbox
sandbox = Sandbox.connect("<YOUR_SANDBOX_ID>")
sandbox.kill()

Sandbox CR method

# Before you run the command, replace <NAMESPACE> with the namespace of the resource and <RESOURCE_NAME> with the actual CR name
kubectl -n <NAMESPACE> delete sandbox <RESOURCE_NAME>

Configure a domain name and certificate

Prepare a domain name

For more information, see Add or delete an Authoritative Zone. Configure the domain names your.domain.com and *.your.domain.com, and resolve them to the address of the Ingress. If access is entirely within the ACS cluster, you can also directly use the in-cluster Headless Service address: sandbox-manager.sandbox-system.svc.cluster.local.

Apply for a certificate

The E2B client must request the backend over the HTTPS protocol. In production scenarios, we recommend that you use the following methods to apply for a certificate.

(Recommended) Method 1: Manage certificates by using cert-manager

The following steps provide a best practice for using cert-manager to manage and deploy a self-signed certificate for sandbox-manager. Make sure that the kubectl command line tool is available and that you have the permissions to operate the cert-manager API.

Step 1: Install cert-manager

Refer to the official documentation to install cert-manager v1.14.

Because the latest version uses the community image repository (quay.io), we recommend that you use v1.14.
Step 2: Automatically manage certificates by using cert-manager
  1. In the cert-manager.yaml file, replace *.your.domain.com and your.domain.com with your domain name.

    The sample YAML uses a self-signed CA certificate. You can also use your own CA certificate.
  2. Run the kubectl apply -f cert-manager.yaml command to add the configuration to the ACS cluster.

Step 3: Verify the certificate status
  1. Check whether the certificate is correctly created and issued.

    kubectl get certificates -n sandbox-system
    kubectl describe certificate sandbox-manager-ingress-cert -n sandbox-system
    kubectl describe secret sandbox-manager-tls -n sandbox-system
  2. Check the Ingress status.

    kubectl get ingress sandbox-manager -n sandbox-system
    kubectl describe ingress sandbox-manager -n sandbox-system
Step 4: Configure client trust

If a self-signed certificate is used, the client must trust the root CA certificate.

  1. Obtain the CA certificate.

    kubectl get secret sandbox-manager-tls -n sandbox-system -o jsonpath='{.data.ca\.crt}' | base64 -d > ca.crt
  2. Configure the client. The client must set the environment variable SSL_CERT_FILE to the path of the obtained CA certificate, or add the CA certificate to the system trust store.

    export SSL_CERT_FILE=/path/to/ca.crt

Method 2: Use a self-signed certificate

Step 1: Create a certificate
  1. Create a self-signed certificate by using the generate-certificates.sh script. You can run the following command to view how to use the script.

    bash generate-certificates.sh --help

    Expected output:

    Usage: generate-certificates.sh [OPTIONS]
    Options:
      -d, --domain DOMAIN     Specify certificate domain (default: example.com)
      -o, --output DIR        Specify output directory (default: .)
      -D, --days DAYS         Specify certificate validity days (default: 365)
      -h, --help              Show this help message
    Examples:
      generate-certificates.sh -d myapp.example.com
      generate-certificates.sh --domain api.example.com --days 730
  2. Run the generate-certificates.sh -d your.domain.com command to generate the certificate. After the certificate is generated, the following files are created:

    • fullchain.pem: the public key of the server certificate

    • privkey.pem: the private key of the server certificate

    • ca-fullchain.pem: the public key of the CA certificate

    • ca-privkey.pem: the private key of the CA certificate

    The script generates both a single domain name (your.domain.com) certificate and a wildcard domain name (*.your.domain.com) certificate, and is compatible with the native E2B protocol and the OpenKruise customized E2B protocol.

Step 2: Install the certificate

Run the following command to mount the server certificate to the Ingress of the cluster:

kubectl create secret tls sandbox-manager-tls \
        --cert=fullchain.pem \
        --key=privkey.pem -n sandbox-system
The certificate may take some time to take effect. The exact effective time is determined by the Ingress controller in use.
Step 3: Configure client trust

The client must set the environment variable SSL_CERT_FILE to the path of the CA public key (ca-fullchain.pem) file generated in Step 1:

export SSL_CERT_FILE=/path/to/ca-fullchain.pem
python main.py # Use Python to call the E2B SDK

Method 3: Use an official certificate (Let's Encrypt as an example)

Step 1: Prepare the certificate

The E2B client must request the backend over the HTTPS protocol. In production scenarios, we recommend that you apply for an official domain name certificate.

The following example applies for a free official certificate through Let's Encrypt. A Let's Encrypt certificate has a hard dependency on a public domain name.

  1. Install certbot by using the package manager of your system (such as brew or snap). For more installation information, see the official documentation.

  2. Change the parameters of -d and --email to the wildcard domain name your.domain.com to apply for a certificate. Complete the verification as prompted by the command.

Because the issued certificate includes both a wildcard domain name and a single domain name, you must complete the TXT record verification process twice in a row.
sudo certbot certonly \
  --manual \
  --preferred-challenges=dns \
  --email your-email@example.com \
  --server https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos \
  -d "your.domain.com" \
  -d "*.your.domain.com"
Step 2: Export the certificate
sudo cp /etc/letsencrypt/live/your.domain.com/fullchain.pem ./fullchain.pem
sudo cp /etc/letsencrypt/live/your.domain.com/privkey.pem ./privkey.pem
Step 3: Install the certificate
kubectl create secret tls sandbox-manager-tls \
  --cert=fullchain.pem \
  --key=privkey.pem \
  --namespace=sandbox-system

DNS resolution

Run the following command to view the endpoint information:

kubectl get ingress sandbox-manager -o jsonpath='{range .status.loadBalancer.ingress[*]}{.hostname}{.ip}{"\n"}{end}' -n sandbox-system

Based on the endpoint information in the output, configure DNS resolution for the domain name your.domain.com or *.your.domain.com. For more information about DNS resolution, see Quick links.

  • If the output is an IP address (such as 47.114.***.***), resolve the host record *.your.domain.com to that IP address as an A record.

  • If the output is a domain name (such as alb-*****62roo70i*****.cn-hangzhou.alb.aliyuncsslb.com), resolve the host record *.your.domain.com to the corresponding domain name as a CNAME record.

  • If multiple endpoints are output, you can resolve the record to any one of the endpoints, or configure round-robin for all endpoints.

FAQ

The ack-agent-sandbox-controller add-on fails to install. Error message: RAM Role AliyunCSManagedAgentSandboxRole is not granted

  1. Go to the Resource Access Management (RAM) Roles page, search for AliyunCSManagedAgentSandboxRole, and then click the role name to open the role details page.

  2. On the role details page, select AliyunCSManagedAgentSandboxRolePolicy, and then click Remove Permission.

  3. Grant the permissions again. Click the authorization link.

Sandbox creation times out or returns an errore2b create sandbox: status 500

For various reasons, errors may occur while a sandbox is being obtained, which causes the allocation of a sandbox from the warm pool to fail. By default, Sandbox Manager and SandboxClaim Controller delete the sandbox on which an error occurred and retry allocating a new sandbox. If you need to retain the failed Sandbox instance and its corresponding Pod for troubleshooting, you can add the following parameters when you obtain the sandbox to skip the deletion:

E2B SDK method

In Sandbox.create, use the agreed keys in metadata to declare the target CPU specifications.

from e2b_code_interpreter import Sandbox

sbx = Sandbox.create(template="some-template", timeout=3000, metadata={
    "e2b.agents.kruise.io/reserve-failed-sandbox": "true"
})

SandboxClaim method

Declare the target resource specifications in the spec.inplaceUpdate.resources field of SandboxClaim.

apiVersion: agents.kruise.io/v1alpha1
kind: SandboxClaim
metadata:
  name: code-interpreter-vpa-claim
  namespace: default
spec:
  templateName: code-interpreter
  replicas: 1
  reserveFailedSandbox: true