Send push pool runs through an egress

Use this page when a push pool must take runs whose secrets egress injects, or setup chats. A push pool without an egress never gets these runs; they wait for a host. The egress is a proxy outside the sandbox. It injects each run's secrets into the requests to their hosts, so the sandbox has only stand-ins.

You need:

  • A push pool, as in Provision runners from your own platform.
  • Terraform 1.11 or later, with the provider set up using a token that has the runners scope. See Manage Spotlight with Terraform.
  • A platform whose firewall can limit where the pool's containers connect.
  • To run the egress yourself: a machine or service that keeps a container running, at an HTTPS address that the pool's containers can reach, and a certificate for that address that the runner image trusts.

If your Spotlight deployment runs a platform egress, you can use it instead of your own. Go to Name the egress in the pool, and name spotlight.

Create the egress

Give the egress a token, and keep it where the egress can read it:

data "spotlight_workspace" "acme" {
  slug = "acme"
}

resource "random_password" "egress" {
  length  = 48
  special = false
}

resource "spotlight_egress" "shared" {
  workspace_id  = data.spotlight_workspace.acme.id
  key           = "shared"
  url           = "https://egress.acme.example"
  token         = random_password.egress.result
  token_version = 1
}

output "egress_token" {
  value     = random_password.egress.result
  sensitive = true
}

Run terraform apply. The value of terraform output -raw egress_token is the egress token. Only the egress gets it; runners never do.

Run the egress

Start spotlight egress serve from the runner image, with your certificate and the egress token:

docker run -d --restart unless-stopped --name spotlight-egress \
  -p 443:3128 \
  -v /etc/spotlight/tls:/etc/spotlight/tls:ro \
  -e SPOTLIGHT_URL="https://app.usespotlight.ai" \
  -e SPOTLIGHT_EGRESS_TOKEN="<egress token>" \
  -e SPOTLIGHT_EGRESS_TLS_CERT=/etc/spotlight/tls/cert.pem \
  -e SPOTLIGHT_EGRESS_TLS_KEY=/etc/spotlight/tls/key.pem \
  --entrypoint spotlight \
  ghcr.io/usespotlightai/spotlight-runner:<release> egress serve

The egress logs egress is the shared egress for sandboxes when it listens. If it logs egress stopped, the message before it names the setting to fix; see Settings.

  • To limit where runs may connect, add SPOTLIGHT_EGRESS_ALLOW, as for a host. See Limit where sandboxes can connect.
  • If you put a load balancer in front of the egress, use one that passes TCP through. Runners send CONNECT requests to the egress, and a load balancer that reads HTTP can reject them.

Name the egress in the pool

Add egress to the pool's provision block:

resource "spotlight_runner_pool" "jobs" {
  workspace_id = data.spotlight_workspace.acme.id
  key          = "jobs"
  labels       = ["jobs"]

  provision = {
    url            = "https://provision.acme.example/spotlight"
    secret         = local.provision_secret
    secret_version = 1
    egress         = spotlight_egress.shared.id
  }
}

For the platform egress, set egress = "spotlight" instead. Run terraform apply. The pool is updated in place.

Pass the egress to each runner

Each provision call now carries data.runner.egress. Start the container with its url as SPOTLIGHT_EGRESS_URL, its credential as SPOTLIGHT_EGRESS_PROXY_CREDENTIAL and its traffic as SPOTLIGHT_EGRESS_TRAFFIC, beside SPOTLIGHT_URL and SPOTLIGHT_RUN_TOKEN, as in Start the runner. The credential is good for that one runner, and only through the egress.

Limit the container to egress

Set your platform's firewall so that the pool's containers can connect only to the egress host. Do not allow the Spotlight address: the runner reaches Spotlight through the egress. If the firewall also filters name lookups, let the containers look up the egress host.

Without this limit, the run still works and the secrets that egress injects stay out of the sandbox, but a tool that ignores the proxy connects directly, past the allow-list and the egress's records.

Check that it works

  1. On Runners, the pool's row reads Push pool with egress.
  2. Start a task at a station whose work the pool takes, as in Add a task and move it along a line.
  3. On the task, select View traces, then select the run's row.
  4. The run's details show Egress followed by Enforced, and the connections the run made. The runner in the sandbox reports this state; the firewall setting is what makes it true.

If you see something else:

What you seeWhat to change
Not enforcedThe container could connect to the Spotlight address directly. Set the firewall as in Limit the container to egress.
No Egress lineThe runner had no SPOTLIGHT_EGRESS_URL. Pass data.runner.egress to the container.
The run fails with No runner was provisioned after N attempts. Last failure: not-allowed and Egress URL must be https.Give the egress an https URL.
The runner's log shows Egress does not know this sandbox.Check that the egress has the token of the egress the pool names.

On this page