Skip to main content

Run sandboxed services on a restricted cluster

Retool's JS executor, agent sandbox, and code executor run untrusted code in sandboxes. By default, the code executor runs as a privileged container, and the other two need custom seccomp profiles and some access to their nodes. If your cluster blocks privileged containers, or enforces Pod Security Standards or a policy engine such as Kyverno, use this guide to run these services with as few exceptions as possible.

For what each service needs from your cluster and why, refer to Untrusted code sandboxing.

Requirements​

To complete this guide, you need:

  • Helm chart 6.14.2 or later.
  • Kubernetes 1.33 or later, to run the code executor without a privileged container.

Place the sandboxes on dedicated node pools​

Run the JS executor and agent sandbox on their own node pools. This keeps untrusted code, and the files the chart installs on nodes, away from the nodes that run your other workloads. The agent sandbox's DaemonSets follow its placement.

Follow the steps in Schedule workloads on dedicated node pools, then return to this guide.

Load Retool's AppArmor profiles​

Retool recommends this step for extra security. It's required if your nodes restrict user namespaces with AppArmor, such as Ubuntu 24.04 nodes, or if your policies don't allow the Unconfined AppArmor profile.

Enable both AppArmor installers in values.yaml:

values.yaml
codeExecutor:
appArmorProfileInstaller: ubuntu
rr:
agentSandbox:
appArmorProfileInstaller: ubuntu

Use cos instead of ubuntu on GKE Container-Optimized OS nodes. If you placed the sandboxes on dedicated node pools, also place the AppArmor installer on those pools.

Run the code executor with a seccomp profile​

By default, the code executor runs as a privileged container. On Kubernetes 1.33 or later, switch it to seccomp profile mode, which grants only what NsJail needs:

  1. Set codeExecutor.useSeccompProfile to true in values.yaml:

    values.yaml
    codeExecutor:
    useSeccompProfile: true
  2. Remove codeExecutor.securityContext if you set it. The chart ignores useSeccompProfile when a custom security context is set.

  3. Remove ALLOW_UNSAFE_CODE_EXECUTION, CONTAINER_UNPRIVILEGED_MODE, and DISABLE_IPTABLES_SECURITY_CONFIGURATION from your environment variables if you set them.

Add policy exceptions​

Your cluster's policies must allow the settings that Untrusted code sandboxing lists for each service. Scope the exceptions to the namespace you install Retool in, and to the following workloads:

  • The JS executor and code executor deployments.
  • The agent sandbox pods, which the agent sandbox controller creates for each session.
  • The agent sandbox DaemonSets.
  • The AppArmor installer DaemonSets, if you enabled them.

Pod Security admission applies one level to a whole namespace, and these workloads need the privileged level. If you use it, install Retool in a namespace of its own.

Apply and verify the changes​

Run helm upgrade to apply your changes. Then check that the sandboxes work:

  1. Navigate to the Services Debugging settings page.
  2. In the Code Executor section, check that Supports Nsjail is Yes.
  3. In the App Builder section:
    1. Check that JS Executor is OK.
    2. Run the Agent Sandbox - Start test and check that it's OK.

For details on each check, refer to Debugging settings reference.