Any time AI is spoken about, it's followed up with "and this is how much it's costing us". Cost management/optimization along with overall optimization of Agentic resources is top of mind for everyone in an organization, from the engineer implementing Agents to the CFO trying to figure out how to effectively spend tokens.
In this blog post, you will learn how to set up Agent Substrate Actors and Workers to ensure agentic efficiency.
Prerequisites
To follow along from a hands-on perspective, you will need the following:
- A GKE or Kind cluster (due to the needs for Pod Certificates).
- Substrate installed. You can follow the guide here to do so.
- Clone the Substrate repo (demos and such that can be run from there).
If you don't have a cluster readily available, you can follow along from a theoretical perspective and configure it at a later time.
Tldr; What Is Substrate?
API/management plane + k8s Worker Nodes.
Substrate implements its own control plane as it's built with more efficiency and optimization for the era of AI Agents. However, k8s is still the best place to cluster resources and have them orchestrated. Substrate combines what it's best at with what Kubernetes is best at.
With Substrate, you have Workers (Kubernetes Pods) and Actors (Agents running inside said Pods).
More here: https://www.cloudnativedeepdive.com/agent-substrate-the-agentic-ai-isolation-layer-on-k8s/
Deploy The Substrate Demo
The counter demo is a small stateful Go HTTP server that increments an in-memory counter on every request. Deploying it creates the Namespace, Worker Pool and Actor Template.
WorkerPool == the pool of warm k8s Pods that actors get multiplexed onto.
ActorTemplate == the immutable Actor definition/schema. Substrate builds the snapshot from it so new Actors hydrate instantly.
- Deploy the demo.
./hack/install-ate.sh --deploy-demo-counter
- Ensure that the golden snapshot is ready.
kubectl wait --for=condition=Ready actortemplate/counter \
-n ate-demo-counter --timeout=5m
- Check to see that al resources are created.
kubectl get workerpool,actortemplate -n ate-demo-counter
Create An Actor
With the Actor Template and Worker Pool in place, you can now create an Actor from the snapshotted template.
- Create an Actor.
kubectl ate create actor my-counter-1 --template ate-demo-counter/counter
You'll notice that the Actor starts in a SUSPENDED state as there hasn't been any traffic sent to it.
kubectl ate get actor my-counter-1
In the next section, you'll send traffic to the Actor to see it used.
Test The Actor
The first step is to port-forward the router. The route in Substrate routes to Actors by a specific DNS name: <actor-id>.actors.resources.substrate.ate.dev
- Within the terminal, port-forward the router.
kubectl port-forward -n ate-system svc/atenet-router 8000:80
- In another terminal, test the connectivity by sending a request to it.
curl -X POST -H "Host: my-counter-1.actors.resources.substrate.ate.dev" \
http://localhost:8000
The first request triggers an on-demand resume. The Substrate Control Plane then claims a warm Worker (Pod), restores the snapshot into the Sandbox, and forwards the request. This is where a lot of the "magic happens" in Substrate. Instead of having Agents constantly running, they only run when they receive a request. This saves resources and money.
Congrats! You have officially tested and ensured that Actors (Agents) work within your Substrate cluster.
Top comments (0)