Deploy on kind
Goal: run the engine on a local kind cluster and drive a ticket through it.
Prerequisites
- Docker.
- kind.
kubectl.
make kind-up deploys the whole engine on the cluster. It installs the operator and applies one
AgentFlowEngine named afe. The operator reconciles that CR into serve, two workers on the
dry harness, their Services and the sandbox NetworkPolicy. Postgres runs through CloudNativePG,
Redis as a StatefulSet, and the admin namespaces and the worker's RBAC come from
deploy/operator/admin/. The ticket images afe-sandbox:dev, afe-netlock:dev and
afe-egress-proxy:dev are built locally.
The kind installation is one manifest, deploy/kind/engine.yaml. It names the afe-source
ConfigMap, the external afe-postgres and afe-redis Secrets, the afe-sandbox sandbox, the
afe:dev image, the API token and the DNS ndots pin. make kind-up applies the operator first,
then that CR.
The image switch: local build or GHCR
make kind-up builds the images locally and loads them into kind. Valorise AFE_IMAGE_TAG with a
published tag and it builds nothing: every image comes from ghcr.io/agentflowengine/*.
make kind-up AFE_IMAGE_TAG=0.0.0-test.1
With the switch set, serve, the workers and the ticket Pod (sandbox, netlock, and
egress-proxy when the project has egress) pull from ghcr.io/agentflowengine/<image>:<tag> with
imagePullPolicy: IfNotPresent. The tag must exist on the registry: the release pipeline publishes
X.Y.Z and X.Y tags. Anything else stops at ImagePullBackOff. The switch runs the dry harness,
so a clean cluster spends no model token. Without the variable the local path is unchanged:
afe:dev plus kind load. The store preflight probe follows the switch too. The probe pulls the
published afe image. make kind-up installs the operator from the same tag, and the kind operator
suite does too, reusing the ghcr-pull Secret the cluster already holds.
The private packages: GHCR_TOKEN
The five ghcr.io/agentflowengine/* packages are private, so the switch needs a pull token with
read:packages. Put it in GHCR_TOKEN, the environment or .env, which is never committed. Then
make kind-up writes an imagePullSecret named ghcr-pull into afe and afe-sandbox. It
attaches the secret to the default ServiceAccount of each namespace. serve and the workers name
it on their own pod templates. The ticket Pod is created at run time by the engine, so it can only
inherit the secret from default. That is how sandbox, netlock and egress-proxy pull from
GHCR too. Without a token the switch stops with a clear message before the rollout, instead of an
ImagePullBackOff (401). The token never reaches a command line or a file in the repository. The
local path creates no secret.
The repeatable GHCR verification
Accepting the GHCR path must not rest on a manual probe. make kind-ghcr-verify runs the whole path
on a clean cluster and cleans up behind it. It is heavy and stays out of make ci.
make kind-ghcr-verify # a fresh `v0.0.0-test.<n>` tag
make kind-ghcr-verify N=7 # a chosen number
In order:
- create the test branch
test/ghcr-verify-<n>and push the git tagv0.0.0-test.<n>. That tag starts thereleaseworkflow. The step waits for that run and stops if it is not green. No release is created andmainis never touched. make kind-down, thenmake kind-up AFE_IMAGE_TAG=0.0.0-test.<n> LIVE=0withGHCR_TOKENexported: a clean kind that pulls every image fromghcr.io/agentflowengine/*. The image tag drops the leadingvof the git tag.- a throwaway Pod on the
defaultServiceAccount ofafe-sandboxand thesandboximage: the exact pull the ticket Pod will make, before the ticket runs. make kind-test: a ticket reachesdoneon the cluster served by GHCR, on the dry harness.- cleanup, on success and on failure: the cluster, the test branch, the test tag, the five
0.0.0-test.<n>GHCR versions and the buildx cache the release left on the shared runner.
The step needs gh authenticated with read:packages and workflow, plus Docker, kind and
kubectl. It also needs a dedicated pull token in GHCR_TOKEN. It never falls back on the gh
CLI's token, and passes GHCR_TOKEN to make kind-up alone. Deleting the test GHCR versions is
best-effort: it needs delete:packages, and a token without that scope does not fail an otherwise
green run. Re-running it is safe: it picks a fresh tag and removes what it made.
Steps
-
Create the cluster and forward its ports:
make kind-up # cluster `afe`, the operator and its CR, CloudNativePG, Redis, serve, workersmake kind-forward # API on 127.0.0.1:8765, ops on 9464 (serve) and 9465 (a worker); leave it onmake kind-uptakes the token fromAFE_API_TOKENin.env. Without that variable it keeps the token it generated the first time. The token lives only in the cluster's Secret.make kind-upalso picks the model harness. Its last line says which one it chose. It readskind: workers on the dry harness (fake models)orkind: workers on the live harness (real models). Read it before you run a flow. A live cluster spends real tokens.Before it deploys,
make kind-upchecks the host and the store. It verifies the kernel settings the kind node's bridge networking needs (br_netfilter,net.bridge.bridge-nf-call-iptables,net.ipv4.ip_forward) and restores them where the host grants passwordlesssudo. Where it cannot, it warns and keeps going. A host that cannot set them is not a host where kind cannot run. The store probe below is the end-to-end proof. Once the Postgres DSN lands in theafenamespace it runs one throwaway Pod that opens the store. Theafenamespace enforces Pod Securityrestricted, so the Pod carries that profile'ssecurityContext. A Pod that cannot reachafe-pg-rw.afe-data.svc.cluster.local:5432stops the run in seconds with the driver's own message, instead of five minutes ofCrashLoopBackOff.The kind CR pins
ndots: 1onserveand the workers — the operator copies it onto both Pod templates — and the probe Pod pins it too. A Pod otherwise inherits the node's search domain andndots: 5, so a cluster name with fewer than five dots (afe-pg-rw.afe-data.svc.cluster.local) is tried under the node's domain first. On a host whose DNS answers a wildcard for names it does not know, that query leavescluster.localand returns a LAN address, so no Pod reaches the store.ndots: 1resolves any dotted name as it is, so CoreDNS answers and the host DNS is never asked for a cluster name. -
In another terminal, export the token from the Secret and run a ticket:
export AFE_API_TOKEN=$(kubectl --context kind-afe -n afe get secret afe-secrets \-o jsonpath='{.data.AFE_API_TOKEN}' | base64 -d)afe run writer-reviewer -i request.yaml # stops at the approvalafe resume T-0001 approveafe workerscurl -s 127.0.0.1:9465/metrics | grep afe_tickets -
To run on real models, put
OPENROUTER_API_KEYin.env(never committed). A plainmake kind-upthen goes live: it applies thedeploy/kind-liveoverlay and the workers run without--dry. The Secret gets the key. That is the safe default now, so a real key does not stay unused while the workers run fake models.make kind-up LIVE=0forces dry even when the key is present.make kind-up LIVE=1is explicit live. Without the key it stops with a message.- With no key and no
LIVE, the workers stay dry.
Editing
.envand runningmake kind-upagain is enough: it rewrites the Secret and restartsserveand the workers.The running cluster reports its mode too. Query the worker's annotation:
kubectl --context kind-afe -n afe get deploy worker \-o jsonpath='{.metadata.annotations.afe\.dev/model-mode}'# dry or live
Testing the cluster
make kind-test runs the tests against the cluster. Before the first test it waits for the CR to be
Ready, not for the two Deployments the operator owns, and clears the tickets a previous run left
behind.
- the V6e tests run a ticket through two workers and check the metrics. They also scale Redis to
zero (the Pods turn unready and are not restarted), and queue a ticket with no worker. They set
workers.replicason the CR, which the operator reconciles. - the V7b tests run a
gitanddeepflow todone. They delete the ticket Pod after a checkpoint, and check that a worker restores the workspace on a new Pod without running a completed node again. They also check network isolation: a Pod reaches nothing by default, or only an allowlisted host when the project has one. Last, they check that the ticket's Pod and PVC are gone at the end.
make kind-test expects dry workers, and it is not part of make ci. make kind-down deletes
the cluster.
Every GitHub Actions job of this repository runs on the maintainer's self-hosted runner, because the
GitHub-hosted runners are blocked by the billing. runs-on: ubuntu-latest, or any other
GitHub-hosted runner, is forbidden. The guard in tests/ci/test_self_hosted_runner.py fails
make ci on a hosted job, reads every workflow file .yml and .yaml alike, and refuses a
job-level uses: reusable-workflow call. A nightly run repeats make kind-test on the
runner and reports every red test on one kind-regression issue (.github/workflows/kind.yml). It
never blocks make ci or a merge. Without a self-hosted runner, deploy/systemd/install.sh
installs the same run as a user timer on the operator's machine.
The kind workloads carry a CPU and a memory limit too: serve, the workers, Redis and the
CloudNativePG Postgres. The nightly e2e/integration suites and the kind run share one
concurrency group, so two heavy runs never overlap on the runner.
Runner disk hygiene
A self-hosted runner keeps the Docker build cache, the images, the volumes and the uv cache between
jobs. So a nightly kind run would grow the disk by gigabytes each time. The kind job runs
scripts/ci/runner_hygiene.sh guard 20 before make kind-up. It frees the space a previous run
left behind. It stops the job with a clear message when / has fewer than 20 GB free. A
runner cleanup step runs the same script with clean in always(), after make kind-down, so
the space is freed even when the run fails earlier. The nightly e2e and integration jobs reuse
both steps around their heavy step, so one script bounds every heavy run on the shared host.
scripts/ci/runner_hygiene.sh has two subcommands. clean caps the build cache at 3 GB, then
prunes the dangling images, the stopped containers, the unused volumes and the uv cache. It prints
df -h / and docker system df before and after. guard <min-free-gb> runs clean first, then
fails when the free space on / is below the threshold. The script is written for the dedicated
runner. docker volume prune frees every unused volume, which is fine when the only containers on
the host are the throwaway ones a kind run creates.
Troubleshooting
LIVE=1 needs OPENROUTER_API_KEY in .env
make kind-up LIVE=1 ran without the key in .env. Add OPENROUTER_API_KEY=... to .env and
run the command again.
The flow finishes instantly, as if the model were fake
The workers are on the dry harness. make kind-up prints its mode as the last line. The worker's
afe.dev/model-mode annotation also reads dry. Put a real OPENROUTER_API_KEY in .env and run
make kind-up again. If you kept LIVE=0, drop it.
make kind-forward shows nothing on 127.0.0.1:8765
The port forward runs in the foreground and must stay open in its own terminal. Check it is still
running, and that no other process holds port 8765, 9464 or 9465.
afe run or afe resume cannot reach the API
AFE_API_TOKEN in your shell does not match the cluster's Secret, or make kind-forward is not
running. Re-export the token with the command in step 2 and confirm the forward is up.
warning: kind could not set net.ipv4.ip_forward=1 on this host
The host's bridge networking misses a setting the kind node needs and make kind-up could not set
it. The run continues, and the store probe decides: when no Pod reaches the store it fails with the
driver's cause. To clear the warning, set the value yourself (sudo sysctl -w net.ipv4.ip_forward=1, and the same for net.bridge.bridge-nf-call-iptables, loading
br_netfilter when that key does not exist) and run make kind-up again. A host upgrade can reset
these.
store preflight: a Pod in afe cannot reach the Postgres store
The cluster is up but no Pod reaches Postgres. The line above the message is the driver's exact
cause (connection refused, could not translate host name, a timeout). Check the host settings
above first, then the afe-pg-rw Service in afe-data. serve and the workers now report the
same cause in their own error.
A Pod resolves a cluster name to an address outside the cluster
The host's DNS answers a wildcard for names it does not know. The Pod inherits the node's search
domain and ndots: 5, so a cluster name with fewer than five dots is tried under the node's domain
first. That query comes back as a LAN address. serve, the workers and the store probe pin
ndots: 1 in their dnsConfig, which resolves any dotted name as it is. Confirm it inside a Pod:
kubectl --context kind-afe -n afe exec deploy/serve -- cat /etc/resolv.conf reads
options ndots:1.
The operator's serve and workers carry no such pin. On that host, name the store and the broker
in their Secrets with an absolute name, ending in the root dot:
afe-pg-rw.afe-data.svc.cluster.local.. The resolver never adds a search domain to it. The kind
operator suite does the same.