Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
44 changes: 23 additions & 21 deletions openclaw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ repo.

## Quick start (demo)

1. Install Substrate on a GKE cluster from a Substrate checkout with
`hack/install-ate.sh --deploy-ate-system`. Create the cluster with the
PodCertificate beta APIs enabled, and set up the snapshot bucket and its IAM
first; see [`demo/README.md`](demo/README.md) Step 1. (The packaged installer
at [`ai-on-gke/substrate-gke`](https://github.com/ai-on-gke/substrate-gke) does
all of that for you, but its pre-built image track is not usable yet.)
1. Install Substrate v1.0.0 on a GKE cluster. The packaged installer at
[`ai-on-gke/substrate-gke`](https://github.com/ai-on-gke/substrate-gke) does
the cluster, bucket, IAM and install for you; or follow
[`demo/README.md`](demo/README.md) Step 1, which uses Substrate's `ate-setup`
with the published release images. Either way, allow the gateway and
dashboard identities through the router (`--ingress-allowed-spiffe-ids`, see
Step 1).
2. `export PROJECT_ID=… GCS_BUCKET=… GEMINI_API_KEY=…`
3. `cd demo && ./deploy-demo.sh` builds the images, pins them by digest, deploys
the WorkerPool, ActorTemplate, and gateway, then prints next steps (link
Expand All @@ -76,24 +77,25 @@ repo.
- **Config only, per deployment**: set `plugins.entries.substrate` on the gateway
(atespace, golden template, actor token, idle timeout) and ACP bindings in
`openclaw.json`. The actor image runs stock OpenClaw with no plugin.
- **On the Substrate side** (targets current OSS `agent-substrate/substrate`,
CRD group `ate.dev`): apply the `WorkerPool` + `ActorTemplate` manifests
(`ate.dev/v1alpha1`), point the gVisor `SandboxConfig` at a runsc build that
survives a heavy multi-process Node.js actor, and apply the control-plane
changes below. Actors use the **atespace** model
(`kubectl ate create atespace <a>; kubectl ate create actor <n> -a <a> --template-ref <name>`,
`--template` on Substrate main) and are reached through the atenet router, addressed
by Host `<actor>.<atespace>.actors.resources.substrate.ate.dev` on release-0.1 and by
the `ate-target-actor: <atespace>/<actor>` header on main. The gateway sends both.
- **On the Substrate side** (targets Agent Substrate v1.0.0, CRD group
`ate.dev/v1`): apply the `WorkerPool` (`ate.dev/v1`) and create the
`ActorTemplate` through the API. Actors use the **atespace** model
(`kubectl ate create atespace <a>; kubectl ate create actor <n> -a <a> --template <name>`)
and are reached through the atenet router over HTTPS, addressed by the
`ate-target-actor: <atespace>/<actor>` header. The router only accepts clients
with a pod identity certificate on the install's allowlist, so the gateway
mounts one (`manifests/gateway.yaml`). Egress is deny by default with a policy
per actor; the plugin creates an allow-all policy for each actor it creates
(`EGRESS_POLICY_FILE` for a tighter one).

### Substrate configuration this needs

It runs on stock Substrate. Earlier revisions of this file listed six
control-plane patches as prerequisites, and that list is obsolete. The cluster
behind [Measured latency](docs/ARCHITECTURE.md#measured-latency) runs `v0.1.0`
images for `atecontroller`, `atelet`, `ateom-gvisor` and `atenet` with no source
changes, the `gvisor-default` `SandboxConfig` exactly as the installer ships it,
and the default 20s golden warmup. No pinned runsc.
It runs on stock Substrate, with the `gvisor-default` `SandboxConfig` exactly as
the installer ships it and the default 20s golden warmup. No pinned runsc.
Earlier revisions of this file listed six control-plane patches as
prerequisites, and that list is obsolete. (The figures in
[Measured latency](docs/ARCHITECTURE.md#measured-latency) were taken on the
earlier `v0.1.0` images.)

Two of the retired claims were wrong rather than merely stale, and
[`substrate-patches/README.md`](substrate-patches/README.md) records them so they
Expand Down
6 changes: 3 additions & 3 deletions openclaw/build/gateway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# today: the toolchain is not auto-downloadable in this build environment, so a
# repo bump to a newer Go fails the build outright.
FROM golang:1.27-bookworm AS ate
# Head of the `release-0.1` branch, pinned by SHA rather than by branch name:
# release-0.1 was cut clean off main and still moves as fixes are picked into it.
ARG SUBSTRATE_REF=c48b3a3c
# The Substrate v1.0.0 release tag, matching the control plane deploy-demo.sh
# installs from the release images.
ARG SUBSTRATE_REF=v1.0.0
RUN git clone --filter=blob:none https://github.com/agent-substrate/substrate.git /src \
&& cd /src && git checkout "$SUBSTRATE_REF" \
&& CGO_ENABLED=0 go build -o /out/kubectl-ate ./cmd/kubectl-ate
Expand Down
96 changes: 49 additions & 47 deletions openclaw/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ WhatsApp user
configured against it, and **Agent Substrate installed** on it (all of Step 1).
- **gcloud** authenticated to a GCP project (`gcloud auth login`), with **Cloud Build**,
**Container Registry**, and **Cloud Storage** enabled.
- On your PATH: `kubectl`, `gcloud`, `go` (to build the Substrate CLI), and
[`ko`](https://ko.build) (the deploy script builds ateom with it).
- On your PATH: `kubectl`, `gcloud`, `go` (to run `ate-setup` and build the
Substrate CLI), `jq`, and [`crane`](https://github.com/google/go-containerregistry/tree/main/cmd/crane)
(the deploy script resolves the release's worker image with it).
- A **GCS bucket** for golden snapshots, with **both** `atelet` and `ate-api-server`
granted `roles/storage.objectAdmin` and `roles/storage.bucketViewer` on it. The
from-source install in Step 1 provisions no GCP resources at all, so this one is
yours to do. `go run github.com/ai-on-gke/substrate-gke/tools/setup-gcp@main bootstrap` does
install in Step 1 provisions no GCP resources at all, so this one is yours to
do (or let the packaged installer do it). `go run github.com/ai-on-gke/substrate-gke/tools/setup-gcp@main bootstrap` does
it, and is idempotent against a bucket that already exists, or by hand:

```bash
Expand All @@ -59,6 +60,21 @@ WhatsApp user
*second* fails with `storage.objects.list` denied and wedges the actor. See the
note under Step 5. The full role table is in
[`tools/setup-gcp/README.md`](https://github.com/ai-on-gke/substrate-gke/blob/main/tools/setup-gcp/README.md).
- **Read access to your image registry** for the nodes and for atelet. The
setup-gcp bootstrap gives the nodes their own service account
(`ate-gke-node`) with read on Substrate's image repository only, so the
gateway image (pulled by the nodes) and the actor image (pulled by atelet)
need a grant on the repository this demo pushes to (`gcr.io/$PROJECT_ID` is the
`gcr.io` repository in `us`). Without it the gateway sits in `ErrImagePull`:

```bash
PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" --format='value(projectNumber)')
for m in "serviceAccount:ate-gke-node@$PROJECT_ID.iam.gserviceaccount.com" \
"principal://iam.googleapis.com/projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$PROJECT_ID.svc.id.goog/subject/ns/ate-system/sa/atelet"; do
gcloud artifacts repositories add-iam-policy-binding gcr.io --location us \
--project "$PROJECT_ID" --member="$m" --role=roles/artifactregistry.reader
done
```
- A **Gemini API key**.
- A phone with **WhatsApp**.
- **gVisor / runsc note:** the actor is a heavy multi-process Node.js workload, but
Expand Down Expand Up @@ -94,78 +110,64 @@ supported in static kubelet mode`. Recreate the node pools afterwards, then
re-run the install to restore the `ate.dev/substrate-version` node label the
recreated pools drop.

**Then install:**
**Then install** Substrate v1.0.0 from its published release images, with the
gateway and dashboard on the ingress allowlist (the router accepts no client
that isn't listed):

```bash
git clone https://github.com/agent-substrate/substrate.git
git clone --branch v1.0.0 https://github.com/agent-substrate/substrate.git
cd substrate
cp hack/ate-dev-env.sh.example .ate-dev-env.sh # then edit for your project/cluster
hack/install-ate.sh --deploy-ate-system
BUCKET_NAME="$GCS_BUCKET" SNAPSHOT_LOCATION="gs://$GCS_BUCKET/openclaw/" \
SNAPSHOT_TRANSFER_GSA_NAME=ate-snapshot-transfer \
ATE_IMAGE_REPO=ghcr.io/agent-substrate/substrate ATE_IMAGE_TAG=v1.0.0 \
go run ./cmd/ate-setup deploy ate-system \
--credential-provider='{"name":"k8s.io"}' \
--ingress-allowed-spiffe-ids=spiffe://cluster.local/ns/openclaw/sa/openclaw-gateway,spiffe://cluster.local/ns/openclaw/sa/openclaw-dashboard
```

It builds the control plane with ko and installs it, and it provisions no GCP
resources, so the snapshot bucket and its IAM bindings are yours to create first
(see Prerequisites). It also cannot upgrade a cluster installed from an older
build in place; see
`ate-setup` installs the control plane from the release images, so no ko or
docker build is needed. It provisions no GCP resources: the snapshot bucket, its
IAM and the `ate-snapshot-transfer` service account come from
`go run github.com/ai-on-gke/substrate-gke/tools/setup-gcp@main bootstrap` (see
Prerequisites). To upgrade a cluster installed from an older build, see
[`docs/guides/upgrade.md`](https://github.com/agent-substrate/substrate/blob/main/docs/guides/upgrade.md).

Keep this checkout. Step 3 builds the worker pods' `ateom` from it, so that
component matches the control plane you just installed.

<details>
<summary>The packaged installer (not usable yet)</summary>

The packaged installer at
[`ai-on-gke/substrate-gke`](https://github.com/ai-on-gke/substrate-gke) wraps all
of the above in an interactive wizard (`make run`, or `make doctor` for preflight
checks only) and provisions the GCP resources for you, including the bucket and
its IAM. It is the nicer path and will become the recommended one.

It does not work yet. Its default track installs pre-built release images, and at
v0.1.0 those are not readable outside the project that publishes them, so the
pull fails with 403 and the installer reports it as an unrelated rollout timeout
(`waiting for deployment/podcertificate-controller ...: client rate limiter Wait
returned an error`), which never mentions an image pull. Use the from-source path
above until that is fixed.
</details>
of the above in an interactive wizard (`make run`) and provisions the GCP
resources for you. Enter the two SPIFFE IDs above when it asks for your clients.

You also need the `kubectl-ate` CLI on your PATH, built from the same Substrate
commit the control plane runs. From that same checkout:
You also need the `kubectl-ate` CLI on your PATH, from the same release:

```bash
make build-atectl && export PATH="$PWD/bin:$PATH"
go install ./cmd/kubectl-ate
```

Verify:

```bash
kubectl -n ate-system get pods # ate-api-server, atelet-<version>, atecontroller, atenet-*, postgres, valkey
kubectl -n ate-system get pods # ate-api-server, atelet, ate-controller, atenet-*, postgres
kubectl ate --version
```

> Pinned to Substrate **`c48b3a3c`**, the head of the `release-0.1` branch that
> v0.1.0 is cut from. Pinned by SHA and not by branch name, since release-0.1 was
> cut clean off main and still moves. Earlier commits will not work: ActorTemplate
> stopped being a Kubernetes CRD, and `WorkerPool.spec.ateomImage` was renamed to
> `workerImage`.
> Targets Substrate **v1.0.0**. Earlier releases will not work: v1 moved the CRDs
> to `ate.dev/v1`, reshaped the ActorTemplate, and made actor ingress HTTPS-only
> with a client allowlist.

## Step 2: Set your config

```bash
export PROJECT_ID="your-gcp-project" # for gcr.io/<project>/openclaw-*
export GCS_BUCKET="your-snapshot-bucket" # no gs:// prefix; must already exist
export GEMINI_API_KEY="..." # LLM provider key
export SUBSTRATE_REPO=/path/to/substrate # the checkout from Step 1
# optional:
# export ATEOM_IMAGE=... # prebuilt ateom-gvisor from that same commit,
# # instead of building it from SUBSTRATE_REPO
# export SUBSTRATE_REPO=/path/to/substrate # the v1.0.0 checkout, to have the script install Substrate
# export ATEOM_IMAGE=... # worker image override; default is the release's ateworker-gvisor
# export WHATSAPP_PEER="+1..." # enable scheduled status pings (E.164)
```

`SUBSTRATE_REPO` is required unless you set `ATEOM_IMAGE`. The worker pods' ateom
has to be built from the same commit the control plane was installed from,
because it speaks internal protos to atelet and ateapi, and a skewed build fails
golden resume with an opaque error instead of a version message. The script
builds it for you with `ko`, so you need `ko` on your PATH too.
The worker pods run the release's own `ateworker-gvisor`, pinned by digest, so
they match the control plane; resolving it needs `crane` on your PATH.

## Step 3: Deploy

Expand Down Expand Up @@ -315,7 +317,7 @@ They are not. The timeline is per-actor and says what the control plane did,
newest first. The event stream is per-operation and says what was asked of it,
including what it refused: burst more actors than the pool has workers and the
excess come back `no worker free (HTTP 503)`, which is the only place the
one-actor-per-ateom rule is visible.
one-awake-actor-per-worker rule is visible.

Layout changes are checked rather than eyeballed. [`dashboard/preview/`](dashboard/preview/)
serves the page's HTML straight out of `dashboard.js` next to a captured
Expand Down
2 changes: 1 addition & 1 deletion openclaw/demo/dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# sent none. The dashboard then showed no actors at all while the pod stayed
# green and the API returned a clean empty list.
FROM golang:1.27-bookworm AS ate
ARG SUBSTRATE_COMMIT=c48b3a3c1ac1122dd49da448abe39151681dc271
ARG SUBSTRATE_COMMIT=v1.0.0
RUN git clone --filter=blob:none https://github.com/agent-substrate/substrate.git /src \
&& git -C /src checkout --detach "${SUBSTRATE_COMMIT}" \
&& cd /src && CGO_ENABLED=0 go build -o /out/kubectl-ate ./cmd/kubectl-ate
Expand Down
79 changes: 67 additions & 12 deletions openclaw/demo/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { exec } from "node:child_process";
import fs from "node:fs";
import http from "node:http";
import https from "node:https";
import os from "node:os";
import path from "node:path";

const app = new Hono();

Expand All @@ -23,7 +27,22 @@ const ATE_NS = "ate-system";
const ATE_ENDPOINT = process.env.ATE_ENDPOINT || "api.ate-system.svc.cluster.local:443";
const GATEWAY_URL = process.env.GATEWAY_URL || `http://openclaw-gateway.${NS}.svc.cluster.local:18789`;
const KUBECTL_ATE = process.env.KUBECTL_ATE || "kubectl-ate";
const ROUTER_URL = process.env.ROUTER_URL || "http://atenet-router.ate-system.svc.cluster.local:80";
// Substrate v1 serves actor ingress only over HTTPS, to a client with a pod
// identity certificate on the install's allowlist (see k8s-manifest.yaml).
const ROUTER_URL = process.env.ROUTER_URL || "https://atenet-router.ate-system.svc:443";
const ROUTER_CLIENT_BUNDLE = process.env.ROUTER_CLIENT_BUNDLE || "/run/router-client/credential-bundle.pem";
const ROUTER_TRUST_BUNDLE = process.env.ROUTER_TRUST_BUNDLE || "/run/router-client/router-trust-bundle.pem";
let routerTls;
// An https.Agent with the current certificate, rebuilt when the kubelet rotates it.
function routerAgent() {
const key = `${fs.statSync(ROUTER_CLIENT_BUNDLE).mtimeMs}:${fs.statSync(ROUTER_TRUST_BUNDLE).mtimeMs}`;
if (!routerTls || routerTls.key !== key) {
const pem = fs.readFileSync(ROUTER_CLIENT_BUNDLE);
routerTls?.agent.destroy();
routerTls = { key, agent: new https.Agent({ keepAlive: true, key: pem, cert: pem, ca: fs.readFileSync(ROUTER_TRUST_BUNDLE) }) };
}
return routerTls.agent;
}
// Atespace(s) the demo actors live in (current OSS actor model). Comma-separated.
const ATESPACES = (process.env.ATESPACES || "openclaw-demo").split(",").map(s => s.trim()).filter(Boolean);

Expand Down Expand Up @@ -455,13 +474,25 @@ const churn = { running: false, stop: false, until: 0, cycles: 0, refused: 0, fa
// because fetch quietly replaces a Host it is given with the URL's.
function pingActor(name, atespace, timeoutMs) {
return new Promise((resolve) => {
const req = http.get(
new URL("/healthz", ROUTER_URL),
const url = new URL("/healthz", ROUTER_URL);
const tls = url.protocol === "https:";
let agent;
try {
agent = tls ? routerAgent() : undefined;
} catch {
resolve(0); // certificate not projected yet
return;
}
const req = (tls ? https : http).get(
url,
{
// v1 routes only on ate-target-actor; Host routing is release-0.1 and
// plain HTTP only.
headers: {
Host: `${name}.${atespace}.actors.resources.substrate.ate.dev`,
...(tls ? {} : { Host: `${name}.${atespace}.actors.resources.substrate.ate.dev` }),
"ate-target-actor": `${atespace}/${name}`,
},
agent,
timeout: timeoutMs,
},
(res) => {
Expand All @@ -474,11 +505,19 @@ function pingActor(name, atespace, timeoutMs) {
});
}

// release-0.1's kubectl-ate spells the flag --template-ref and main's spells it
// --template (substrate#1536); this image pins the first, a main checkout builds
// the second. Try both, count "already exists" as success, and put any other
// v1's kubectl-ate spells the flag --template, release-0.1's spelled it
// --template-ref (substrate#1536). Try both, count "already exists" as success, and put any other
// failure on the timeline: an actor that was silently never created is what
// used to make burst report success while the pod map stayed empty.
let egressPolicyPath;
function egressPolicyFile() {
if (!egressPolicyPath) {
egressPolicyPath = path.join(os.tmpdir(), "openclaw-egress-policy.yaml");
fs.writeFileSync(egressPolicyPath, 'rules:\n- http: {hostnames: ["*"], ports: {all: {}}}\n- https: {hostnames: ["*"]}\n');
}
return egressPolicyPath;
}

function createFleetActor(name, atespace) {
const attempt = (flag) =>
new Promise((resolve) =>
Expand All @@ -489,11 +528,27 @@ function createFleetActor(name, atespace) {
)
);
return (async () => {
let err = await attempt("--template-ref");
if (/unknown flag/i.test(err)) err = await attempt("--template");
if (!err || /already exists/i.test(err)) return true;
addEvent("substrate", `${name}: create failed: ${err.split("\n")[0]}`);
return false;
let err = await attempt("--template");
if (/unknown flag/i.test(err)) err = await attempt("--template-ref");
if (err && !/already exists/i.test(err)) {
addEvent("substrate", `${name}: create failed: ${err.split("\n")[0]}`);
return false;
}
// Substrate v1 denies an actor's egress until it has a policy; allow any
// host over HTTP and HTTPS, as release-0.1 did. "unknown command" is
// release-0.1, which has no egress policies.
const perr = await new Promise((resolve) =>
exec(
`${KUBECTL_ATE} create egress-policy ${name} -a ${atespace} -f ${egressPolicyFile()}`,
{ timeout: 15000 },
(error, _stdout, stderr) => resolve(error ? (stderr || error.message).trim() : "")
)
);
if (perr && !/already exists|unknown command/i.test(perr)) {
addEvent("substrate", `${name}: egress policy failed: ${perr.split("\n")[0]}`);
return false;
}
return true;
})();
}

Expand Down
Loading
Loading