<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Michael Levan</title>
    <description>The latest articles on DEV Community by Michael Levan (@thenjdevopsguy).</description>
    <link>https://dev.to/thenjdevopsguy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F332370%2F1b619a84-879e-4a1a-8f24-4098fb7a1168.png</url>
      <title>DEV Community: Michael Levan</title>
      <link>https://dev.to/thenjdevopsguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thenjdevopsguy"/>
    <language>en</language>
    <item>
      <title>OpenEnv + Agent Substrate: Run Agentic RL In Isolated Sandboxes</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sun, 15 Nov 2026 20:38:43 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/openenv-agent-substrate-run-agentic-rl-in-isolated-sandboxes-273l</link>
      <guid>https://dev.to/thenjdevopsguy/openenv-agent-substrate-run-agentic-rl-in-isolated-sandboxes-273l</guid>
      <description>&lt;p&gt;One of the most amazing advancements of Agents is that when you ask a question, it's not a "one question &amp;gt; one answer &amp;gt; stop" motion. You ask a question, and your Agents can go through many attempts to complete a task.&lt;/p&gt;

&lt;p&gt;This helps when completing one of the things you're working on, but it's also paramount for Model success in post-training.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn what the post-training portion is with Agentic RL and how to implement RL environments in Agent Substrate to protect the system it runs on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post in a hands-on fashion, there is a list of requirements below. If you don't have these requirements/infrastructure, however, it's still good to read through this blog from a theoretical perspective. That way, you have everything you need once you bring the infra/env online.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GKE cluster or any cluster that can run Agent Substrate.&lt;/li&gt;
&lt;li&gt;An L4 quota (for the NVIDIA GPUs).&lt;/li&gt;
&lt;li&gt;Agent Substrate installed.&lt;/li&gt;
&lt;li&gt;Roughly 10-12 GB of free memory (for the CPU node pool).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's Agentic RL?
&lt;/h2&gt;

&lt;p&gt;RL stands for "Reinforcement Learning"&lt;/p&gt;

&lt;p&gt;TLDR; it's a way to have an Agent perform multiple tasks (e.g., this test failed, figure out why), learn from those tasks (many attempts per task), and update the weights in the LLMs that the Agent used after the tasks are done with what it learned. This happens at training time (usually post-training).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmzpsr95rrof334i9un4k.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmzpsr95rrof334i9un4k.gif" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For Agentic RL to work within Kubernetes, you'll use OpenEnv, one of the latest projects donated to the AAIF.&lt;/p&gt;

&lt;p&gt;💡Throughout your RL journey, you may see a new definition to understand: Group Relative Policy Optimization (GRPO). GRPO is a reinforcement learning algorithm (originally introduced by DeekSeek) to train LLMs in complex reasoning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Agent Substrate?
&lt;/h2&gt;

&lt;p&gt;Agentic RL, like OpenEnv, needs a system to run on, and since the LLM is running untrusted actions inside the env, that system should be a secure/isolated sandbox.&lt;/p&gt;

&lt;p&gt;Why? Because when running an environment for Agentic RL, there could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Destructive Actions (e.g., &lt;code&gt;rm -rf&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Escape and lateral movements&lt;/li&gt;
&lt;li&gt;"Reward hacking" because Agentic RL is optimized for the reward (a completed task)&lt;/li&gt;
&lt;li&gt;Scale&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly why Agent Substrate is the perfect place.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffqjw35lkpn8ck5p52mgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffqjw35lkpn8ck5p52mgc.png" alt=" " width="799" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💡 This is exactly what happened with the OpenAI/Hugging Face attack. Agentic RL was going on, and because "reward hacking" is a failure mode of Agentic RL, the Agent decided to break out of the env so it could complete its task.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Runs In Substrate?
&lt;/h3&gt;

&lt;p&gt;As far as what runs in Substrate, the environment itself will run within Agent Substrate. This includes the OpenEnv env servers (one per Actor), the Harness, and the Graders (keep the answer files/grading logic where the Agent can't reach). The Models, training, and GPU-intensive workloads will run outside of Agent Substrate.&lt;/p&gt;

&lt;p&gt;The environment as a whole, however, runs directly on Kubernetes. Throughout this blog post, you will see a lot of technologies used, from agentgateway to vLLM to GPU-related tasks for the training and open-weight Models running, all within k8s.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvvqarhi6t7dwoflqx2m9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvvqarhi6t7dwoflqx2m9.png" alt=" " width="620" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Where Does Agentgateway Come Into Play?
&lt;/h3&gt;

&lt;p&gt;Agentgateway is at the evaluation stage where the LLM calls are real HTTP. The two primary reasons that the training loop doesn't go through agentgateway are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The run inside the training process never crosses the network, so there's no hop to a proxy.&lt;/li&gt;
&lt;li&gt;Substrate doesn't pass GPUs through to Actors, so the trainer and vLLM are ordinary GPU Pods next to Substrate, not inside of it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Env Vars
&lt;/h3&gt;

&lt;p&gt;For this blog post, you'll need to set a few environment variables within the terminals that you plan on working in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${HOME}/gitrepos/substrate"&lt;/span&gt;   &lt;span class="c"&gt;# checkout of the Substrate you installed&lt;/span&gt;

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;           &lt;span class="c"&gt;# GCP project of the cluster&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLUSTER_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;substrate
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLUSTER_LOCATION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;us-central1-a

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ATESPACE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rl-lab
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;POOL_NS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ate-rl-lab
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;TRAIN_NS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rl-train
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;LLM_NS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;agentgateway-system
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;LLM_GW&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rl-llm
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;NUM_ACTORS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8          &lt;span class="c"&gt;# one environment per GRPO rollout slot&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Qwen/Qwen3-1.7B

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ROUTER_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://atenet-router.ate-system.svc.cluster.local

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KO_DOCKER_REPO&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;       &lt;span class="c"&gt;# registry your cluster pulls from&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KO_DEFAULTPLATFORMS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"linux/amd64"&lt;/span&gt;

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CODING_ENV_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ghcr.io/huggingface/openenv-coding-env@sha256:995ebc9b443c29a14882a0ad1b37ed26d5e9086bd85500e49e9d06c18295bda6'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;VLLM_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'vllm/vllm-openai:v0.31.0@sha256:c1c9f6fd5c109ba7f0546a59f5b2f15fb87f64c77782e90a27b648b42a8e67c3'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PYTHON_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'python:3.12-slim@sha256:a0f57064cbdcd6285fa45f51237ab0b35ea8ebaed06a1f5973e89e19dfb86704'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CURL_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'curlimages/curl:8.22.0@sha256:58adaa4e8dca9c988bae2aba4ab3434a0bb2da16bbe3f92dec39ec7785166777'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Worker Nodes and WorkerPool
&lt;/h2&gt;

&lt;p&gt;With the theory of post-training known, along with where Agent Substrate comes into play, let's start the hands-on portion of setting up the Substrate environment for RL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ensure everything is running as expected in the Substrate ecosystem:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl -n ate-system get pods
kubectl -n ate-system get svc atenet-router \
  -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{range .spec.ports[*]}{.name}={.port}{"\n"}{end}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The trainer and vLLM need a GPU. The Substrate Workers stay on CPU as the Workers don't need GPUs due to the GPU workloads staying outside of Substrate. Add a node pool in your cluster for GPUs.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud container node-pools create gpu-l4 \
  --cluster=&lt;span class="s2"&gt;"${CLUSTER_NAME}"&lt;/span&gt; --location=&lt;span class="s2"&gt;"${CLUSTER_LOCATION}"&lt;/span&gt; --project=&lt;span class="s2"&gt;"${PROJECT_ID}"&lt;/span&gt; \
  --machine-type=g2-standard-8 \
  --accelerator=type=nvidia-l4,count=1,gpu-driver-version=latest \
  --num-nodes=1 \
  --workload-metadata=GKE_METADATA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create the &lt;code&gt;WorkerPool&lt;/code&gt;. The target environment is ten Workers and 8 env Actors.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;cat &amp;lt;&amp;lt;EOF | hack/run-tool.sh ko apply -f -&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Namespace&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${POOL_NS}&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate.dev/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;WorkerPool&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rl-lab&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${POOL_NS}&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;workload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rl-lab&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
  &lt;span class="na"&gt;workerImage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ko://go.ate.dev/substrate/cmd/ateworker-gvisor&lt;/span&gt;
  &lt;span class="na"&gt;sandboxClasses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gvisor&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1Gi&lt;/span&gt;
      &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;250m&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1Gi&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should now see your Workers and Pools up and operational.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5attoao9xiwzio1esn4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5attoao9xiwzio1esn4f.png" alt=" " width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Router Identity
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;atenet-router&lt;/code&gt; lets a client reach Actors only if the clients SPIFEE ID is on its &lt;code&gt;allowList&lt;/code&gt;. Add the &lt;code&gt;ServiceAccount&lt;/code&gt; that the trainer and the eval will run as so it can run against the Actor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run ./cmd/ate-setup deploy atenet \
  --config &lt;span class="s2"&gt;"${INSTALL_RECORD}"&lt;/span&gt; \
  --ingress-allowed-spiffe-ids=&lt;span class="s2"&gt;"spiffe://cluster.local/ns/ate-system/sa/atenet-client,spiffe://cluster.local/ns/${TRAIN_NS}/sa/${ROUTER_CLIENT_SA}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The env vars come from the section above when you're setting them in your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Actor Configuration
&lt;/h2&gt;

&lt;p&gt;In the previous section, you deployed ten Workers, which means the goal is to run Actors. However, Actors don't actually run the training. Instead, they run the environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trainer Job (GPU pod, ordinary Kubernetes, outside Substrate): holds the Model, performs generation (vLLM co-located in the same process), computes the GRPO loss, and updates the LoRA weights.&lt;/li&gt;
&lt;li&gt;Eight actors (&lt;code&gt;coder-0..7&lt;/code&gt;, gVisor sandboxes on Substrate): each is an OpenEnv coding server. They receive the Python code the model wrote, execute it, and return &lt;code&gt;stdout&lt;/code&gt;, &lt;code&gt;stderr&lt;/code&gt;, and &lt;code&gt;exit_code&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flac8vet37po1zn9lou8e.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flac8vet37po1zn9lou8e.gif" alt=" " width="760" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tldr; the Actor executes the runs and grades them. The trainer learns.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the Actor Template.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate create atespace &lt;span class="s2"&gt;"${ATESPACE}"&lt;/span&gt;

sed \
  -e &lt;span class="s2"&gt;"s|@ATESPACE@|${ATESPACE}|g"&lt;/span&gt; \
  -e &lt;span class="s2"&gt;"s|@IMAGE@|${CODING_ENV_IMAGE}|g"&lt;/span&gt; \
  &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; kubectl ate create actor-template -f -
metadata:
  atespace: @ATESPACE@
  name: coding-env
workerSelector:
  matchLabels:
    workload: rl-lab
containers:
- name: env
  image: @IMAGE@
  command: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"uvicorn"&lt;/span&gt;, &lt;span class="s2"&gt;"coding_env.server.app:app"&lt;/span&gt;, &lt;span class="s2"&gt;"--host"&lt;/span&gt;, &lt;span class="s2"&gt;"0.0.0.0"&lt;/span&gt;, &lt;span class="s2"&gt;"--port"&lt;/span&gt;, &lt;span class="s2"&gt;"80"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  env:
  - name: ENABLE_WEB_INTERFACE
    value: &lt;span class="s2"&gt;"false"&lt;/span&gt;
  - name: PYTHONUNBUFFERED
    value: &lt;span class="s2"&gt;"1"&lt;/span&gt;
  wakeupProbe:
    httpGet:
      path: /health
      port: 80
    timeoutSeconds: 60
resources:
  limits:
    cpuMillicores: 1000
    memoryBytes: 805306368 &lt;span class="c"&gt;# 768Mi&lt;/span&gt;
snapshotConfig:
  preferredFidelity: SNAPSHOT_FIDELITY_MEMORY
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Based on the template, create eight Actors (one per GRPO rollout slot). The OpenEnv coding server holds one session at a time, so each trainer slot needs its own Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 0 &lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;NUM_ACTORS - 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate create actor &lt;span class="s2"&gt;"coder-${i}"&lt;/span&gt; -a &lt;span class="s2"&gt;"${ATESPACE}"&lt;/span&gt; --template coding-env
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 0 &lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;NUM_ACTORS - 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate resume actor &lt;span class="s2"&gt;"coder-${i}"&lt;/span&gt; -a &lt;span class="s2"&gt;"${ATESPACE}"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
kubectl ate get actors -a &lt;span class="s2"&gt;"${ATESPACE}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create the &lt;code&gt;ServiceAccount&lt;/code&gt; that you put on the routers &lt;code&gt;AllowList&lt;/code&gt; in &lt;strong&gt;Router Identity&lt;/strong&gt; section, along with a PVC that holds the Hugging Face Cache.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF &lt;span class="o"&gt;|&lt;/span&gt; kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
  name: &lt;span class="nv"&gt;${TRAIN_NS}&lt;/span&gt;
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: &lt;span class="nv"&gt;${ROUTER_CLIENT_SA}&lt;/span&gt;
  namespace: &lt;span class="nv"&gt;${TRAIN_NS}&lt;/span&gt;
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rl-data
  namespace: &lt;span class="nv"&gt;${TRAIN_NS}&lt;/span&gt;
spec:
  accessModes: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ReadWriteOnce"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  storageClassName: standard-rwo
  resources:
    requests:
      storage: 50Gi
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Training Job
&lt;/h2&gt;

&lt;p&gt;With the environment, Workers, and Actors up and running, along with the router configs in place (specifying the &lt;code&gt;ServiceAccount&lt;/code&gt; as the identity in the &lt;code&gt;allowlist&lt;/code&gt;), you can now test out the training job.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the config for the trainer's agentgateway sidecar. It listens on plain HTTP at &lt;code&gt;127.0.0.1:8080&lt;/code&gt; inside the Pod and forwards everything to &lt;code&gt;atenet-router&lt;/code&gt; over mTLS, using the Pods cert.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'EOF'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; kubectl -n &lt;span class="s2"&gt;"${TRAIN_NS}"&lt;/span&gt; apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: router-client
data:
  config.yaml: &lt;span class="o"&gt;|&lt;/span&gt;
    gateways:
      local:
        port: 8080
        bindAddress: 127.0.0.1
        protocol: HTTP
    backends:
    - name: atenet-router
      host: atenet-router.ate-system.svc:443
      policies:
        http:
          version: HTTP/1.1
        backendTLS:
          cert: /run/router-client/credential-bundle.pem
          key: /run/router-client/credential-bundle.pem
          root: /run/router-client/router-ca.pem
    routes:
    - name: to-router
      gateways:
      - &lt;span class="kd"&gt;local&lt;/span&gt;
      backends:
      - backend: /atenet-router
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Store the training script (&lt;code&gt;train.py&lt;/code&gt;) in a &lt;code&gt;ConfigMap. The GRPO trainer +&lt;/code&gt;SandboxedPython` sends the Models code to the Actors and scores what comes back. The three env vars set in the script below tell the script where to send and which Actor to name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`python&lt;br&gt;
cat &amp;lt;&amp;lt;'EOF' | kubectl -n "${TRAIN_NS}" apply -f -&lt;br&gt;
apiVersion: v1&lt;br&gt;
kind: ConfigMap&lt;br&gt;
metadata:&lt;br&gt;
  name: rl-scripts&lt;br&gt;
data:&lt;br&gt;
  train.py: |&lt;br&gt;
    import itertools&lt;br&gt;
    import os&lt;br&gt;
    import secrets&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from datasets import load_dataset
from openenv import GenericEnvClient
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer

ROUTER_URL = os.environ["ROUTER_URL"]
ATESPACE = os.environ["ATESPACE"]
NUM_ACTORS = int(os.environ["NUM_ACTORS"])

PROMPT = """You are solving a Python programming task in a sandbox.

Task: {task}

Your function must pass this test:
{example}

Use the run_python tool to try code. When your function is correct, call submit_solution once with the complete function definition."""

_slots = itertools.count()

def to_example(row):
    return {
        "prompt": [{"role": "user", "content": PROMPT.format(task=row["prompt"], example=row["test_list"][0])}],
        "tests": row["test_list"],
    }

class SandboxedPython:
    def __init__(self):
        self.actor = f"coder-{next(_slots) % NUM_ACTORS}"
        self._client = None
        self._tests = []
        self._solution = None

    def _env(self):
        if self._client is None:
            self._client = GenericEnvClient(
                base_url=ROUTER_URL,
                headers={"ate-target-actor": f"{ATESPACE}/{self.actor}"},
            ).sync()
            self._client.connect()
        return self._client

    def reset(self, **kwargs):
        self._tests = kwargs["tests"]
        self._solution = None
        self._env().reset()
        return None

    def run_python(self, code: str) -&amp;gt; str:
        """
        Run Python code in the sandbox and return what it printed.

        Args:
            code: The Python source code to run.

        Returns:
            The exit code, stdout and stderr of the run.
        """
        obs = self._env().step({"code": code}).observation
        return f"exit_code={obs.get('exit_code')}\nstdout:\n{obs.get('stdout', '')}\nstderr:\n{obs.get('stderr', '')}"

    def submit_solution(self, code: str) -&amp;gt; str:
        """
        Submit the final answer. Call this once, with the complete function definition.

        Args:
            code: The complete Python function definition.

        Returns:
            A confirmation that the answer was recorded.
        """
        self._solution = code
        return "Answer recorded."

    def get_reward(self) -&amp;gt; float:
        if not self._solution:
            return 0.0
        env = self._env()
        env.reset()
        nonce = secrets.token_hex(8)
        program = "\n".join([self._solution, *self._tests, f"print('{nonce}')"])
        obs = env.step({"code": program}).observation
        return 1.0 if obs.get("exit_code") == 0 and nonce in obs.get("stdout", "") else 0.0

dataset = load_dataset("google-research-datasets/mbpp", "sanitized", split="train")
dataset = dataset.filter(lambda row: not row["test_imports"])
dataset = dataset.map(to_example, remove_columns=dataset.column_names)

trainer = GRPOTrainer(
    model=os.environ["MODEL"],
    train_dataset=dataset,
    environment_factory=SandboxedPython,
    peft_config=LoraConfig(r=16, lora_alpha=32, target_modules="all-linear", task_type="CAUSAL_LM"),
    args=GRPOConfig(
        output_dir="/data/run",
        use_vllm=True,
        vllm_mode="colocate",
        vllm_gpu_memory_utilization=0.35,
        vllm_max_model_length=4096,
        chat_template_kwargs={"enable_thinking": False},
        num_generations=4,
        per_device_train_batch_size=NUM_ACTORS,
        gradient_accumulation_steps=1,
        max_completion_length=1536,
        max_tool_calling_iterations=6,
        learning_rate=5e-5,
        max_steps=int(os.environ.get("MAX_STEPS", "40")),
        bf16=True,
        gradient_checkpointing=True,
        logging_steps=1,
        log_completions=True,
        num_completions_to_print=1,
        save_strategy="no",
        report_to="none",
    ),
)
trainer.train()
trainer.save_model("/data/adapter")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;EOF&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the training job. The &lt;code&gt;Job&lt;/code&gt; creates the GRPO job and that job is the training run. When you apply the &lt;code&gt;Job&lt;/code&gt;, it does the following.&lt;/li&gt;
&lt;li&gt;

&lt;ol&gt;
&lt;li&gt;Pod schedules on the L4 GPU node, running as &lt;code&gt;rl-client&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Sidecar (agentgateway running as a small proxy) starts first and waits ready on &lt;code&gt;127.0.0.1:8080&lt;/code&gt;. It exists because OpenEnv's Python client can only open a plain WebSocket. It has no way to present a client certificate. The router only accepts mTLS, so the sidecar bridges the two.&lt;/li&gt;
&lt;li&gt;Trainer container pip installs TRL, PEFT, OpenEnv, datasets.&lt;/li&gt;
&lt;li&gt;It runs &lt;code&gt;/opt/lab/train.py&lt;/code&gt;, downloads &lt;code&gt;Qwen3-1.7B&lt;/code&gt;, starts vLLM in-process, then does 40 GRPO steps against the eight actors.&lt;/li&gt;
&lt;li&gt;It saves the LoRA adapter to &lt;code&gt;/data/adapter&lt;/code&gt; on the PVC and the job completes.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;yaml&lt;br&gt;
cat &amp;lt;&amp;lt;EOF | kubectl apply -f -&lt;br&gt;
apiVersion: batch/v1&lt;br&gt;
kind: Job&lt;br&gt;
metadata:&lt;br&gt;
  name: grpo-mbpp&lt;br&gt;
  namespace: ${TRAIN_NS}&lt;br&gt;
spec:&lt;br&gt;
  backoffLimit: 0&lt;br&gt;
  template:&lt;br&gt;
    spec:&lt;br&gt;
      restartPolicy: Never&lt;br&gt;
      serviceAccountName: ${ROUTER_CLIENT_SA}&lt;br&gt;
      nodeSelector:&lt;br&gt;
        cloud.google.com/gke-accelerator: nvidia-l4&lt;br&gt;
      tolerations:&lt;br&gt;
      - key: nvidia.com/gpu&lt;br&gt;
        operator: Exists&lt;br&gt;
        effect: NoSchedule&lt;br&gt;
      initContainers:&lt;br&gt;
      - name: router-client&lt;br&gt;
        image: ${AGW_IMAGE}&lt;br&gt;
        restartPolicy: Always&lt;br&gt;
        args: ["-f", "/etc/agentgateway/config.yaml"]&lt;br&gt;
        startupProbe:&lt;br&gt;
          httpGet:&lt;br&gt;
            path: /healthz/ready&lt;br&gt;
            port: 15021&lt;br&gt;
          periodSeconds: 1&lt;br&gt;
          failureThreshold: 60&lt;br&gt;
        resources:&lt;br&gt;
          requests:&lt;br&gt;
            cpu: 50m&lt;br&gt;
            memory: 64Mi&lt;br&gt;
        volumeMounts:&lt;br&gt;
        - name: router-client-config&lt;br&gt;
          mountPath: /etc/agentgateway&lt;br&gt;
          readOnly: true&lt;br&gt;
        - name: router-client&lt;br&gt;
          mountPath: /run/router-client&lt;br&gt;
          readOnly: true&lt;br&gt;
      containers:&lt;br&gt;
      - name: trainer&lt;br&gt;
        image: ${VLLM_IMAGE}&lt;br&gt;
        command: ["/bin/bash", "-c"]&lt;br&gt;
        args:&lt;br&gt;
        - |&lt;br&gt;
          set -euo pipefail&lt;br&gt;
          pip install --no-cache-dir "trl[peft]==1.16.0" "peft==0.21.2" "openenv==0.10.0" "datasets==5.1.0"&lt;br&gt;
          python /opt/lab/train.py&lt;br&gt;
        env:&lt;br&gt;
        - name: MODEL&lt;br&gt;
          value: "${MODEL}"&lt;br&gt;
        - name: ROUTER_URL&lt;br&gt;
          value: "${ROUTER_URL}"&lt;br&gt;
        - name: ATESPACE&lt;br&gt;
          value: "${ATESPACE}"&lt;br&gt;
        - name: NUM_ACTORS&lt;br&gt;
          value: "${NUM_ACTORS}"&lt;br&gt;
        - name: MAX_STEPS&lt;br&gt;
          value: "40"&lt;br&gt;
        - name: HF_HOME&lt;br&gt;
          value: /data/hf&lt;br&gt;
        - name: PYTHONUNBUFFERED&lt;br&gt;
          value: "1"&lt;br&gt;
        resources:&lt;br&gt;
          requests:&lt;br&gt;
            cpu: "6"&lt;br&gt;
            memory: 20Gi&lt;br&gt;
          limits:&lt;br&gt;
            memory: 26Gi&lt;br&gt;
            nvidia.com/gpu: 1&lt;br&gt;
        volumeMounts:&lt;br&gt;
        - name: scripts&lt;br&gt;
          mountPath: /opt/lab&lt;br&gt;
        - name: data&lt;br&gt;
          mountPath: /data&lt;br&gt;
        - name: shm&lt;br&gt;
          mountPath: /dev/shm&lt;br&gt;
      volumes:&lt;br&gt;
      - name: scripts&lt;br&gt;
        configMap:&lt;br&gt;
          name: rl-scripts&lt;br&gt;
      - name: data&lt;br&gt;
        persistentVolumeClaim:&lt;br&gt;
          claimName: rl-data&lt;br&gt;
      - name: shm&lt;br&gt;
        emptyDir:&lt;br&gt;
          medium: Memory&lt;br&gt;
          sizeLimit: 8Gi&lt;br&gt;
      - name: router-client-config&lt;br&gt;
        configMap:&lt;br&gt;
          name: router-client&lt;br&gt;
      - name: router-client&lt;br&gt;
        projected:&lt;br&gt;
          sources:&lt;br&gt;
          - podCertificate:&lt;br&gt;
              signerName: podidentity.podcert.ate.dev/identity&lt;br&gt;
              keyType: ECDSAP256&lt;br&gt;
              credentialBundlePath: credential-bundle.pem&lt;br&gt;
          - clusterTrustBundle:&lt;br&gt;
              signerName: servicedns.podcert.ate.dev/identity&lt;br&gt;
              labelSelector:&lt;br&gt;
                matchLabels:&lt;br&gt;
                  podcert.ate.dev/canarying: live&lt;br&gt;
              path: router-ca.pem&lt;br&gt;
EOF&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can see the Actors in action while they're running the test program.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;shell&lt;br&gt;
kubectl ate logs actor coder-0 -a "${ATESPACE}" -f --source containers&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fecqtyuld3mt69xxnttfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fecqtyuld3mt69xxnttfs.png" alt=" " width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;If you dove into the OpenAI/Hugging Face attack, this was actually done during an OpenAI RL and evaluation run. Agents faced tasks that seemed "impossible" during the eval run and broke out of the environment. This is why post-training and reinforcement learning are so important. A lot of people say when a new LLM comes out or gets worse, "oh, this one isn't as good as the other LLM" or "this LLM is so much better". In reality, it's not that the LLM got "worse", it's that the RL and post-training "got worse".&lt;/p&gt;

&lt;p&gt;RL and post-training shape how the LLM will behave, reason, and solve problems. It doesn't matter how much information/data the LLM has if the post-training wasn't done properly.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>cloud</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Many Actors, One Worker: Running Multi-Actor Workflows In Agent Substrate</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sun, 18 Oct 2026 13:49:25 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/many-actors-one-worker-running-multi-actor-workflows-in-agent-substrate-jd1</link>
      <guid>https://dev.to/thenjdevopsguy/many-actors-one-worker-running-multi-actor-workflows-in-agent-substrate-jd1</guid>
      <description>&lt;p&gt;Starting with Agent Substrate v0.5.0 (latest build at the time of writing this blog post on 10/17/2026), you can now run multiple Actors within one Worker (Pod). Before this release, only one Actor could run/be scheduled at a time on a Worker.&lt;/p&gt;

&lt;p&gt;This is a phenomenal edition as it showcases an even better story on the efficiency of running Agents within Substrate, separating more and more from the "One Agent, one Pod" model.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn how to set up your Worker to ensure that it has the proper resources to run multiple Actors, along with testing out the flow to see multi-Actor runs on a single Worker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post in a hands-on fashion, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Kubernetes cluster (local is fine)

&lt;ul&gt;
&lt;li&gt;If you go with a managed service like AKS or EKS, you will need k8s v1.37 as it requires the PodCertificate API and AKS/EKS doesn't allow you to modify the Control Plane. Using GKE or a local cluster like Kind/Minikube allows you to modify the Control Plane to enable the PodCertificate API.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Agent Substrate installed. You can learn how to do that here.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;0.5.0&lt;/code&gt; version of &lt;code&gt;kubectl-ate&lt;/code&gt; is installed.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; substrate
git checkout v0.5.0
go install ./cmd/kubectl-ate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Architecture
&lt;/h2&gt;

&lt;p&gt;To fully understand what and how you're going to deploy, let's dive into the architecture to get a good idea of what will run and how it will run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7qgki0v80si0h9atbqsu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7qgki0v80si0h9atbqsu.png" alt=" " width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What you see above are many of the Agent Substrate components that are needed for the system itself to run, and you can learn what those primitives are here. For the purposes of this blog post, let's focus on the &lt;code&gt;WorkerPool&lt;/code&gt;, &lt;code&gt;ActorTemplate&lt;/code&gt;, and &lt;code&gt;Worker&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;WorkerPool&lt;/code&gt; is how many Workers (Pods) are available within the pool. You can think of it like a standard k8s cluster - when deploying a cluster, you have Worker Nodes, and the Worker Nodes resources (CPU, memory, etc.) are "pooled" for the entire cluster to be able to use, so Pods can be scheduled and run with the necessary resources. Same concept.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ActorTemplate&lt;/code&gt; is almost like the "golden image" (although "image" is a bit too heavy of a word). It contains what the Actor (Agent) is going to use to run (its config, image, and snapshot settings). That includes the limits for both CPU and memory.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Worker&lt;/code&gt; is, as mentioned, a k8s Pod. It's where the Actor runs along with the configuration for how the sandbox will run. For example, if you use gVisor, the Worker will contain ateom, which is the execution runner (think of it as the runtime). Each sandbox inside the Worker runs the Actor (Agent).&lt;/p&gt;

&lt;p&gt;In the sections to come, you will learn how to configure resources on Workers and run the Actors within said Workers to ensure that you can have multiple Actors running in one Worker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Workers With Proper Resources
&lt;/h2&gt;

&lt;p&gt;By default, a Worker's default capacity for Actor count is 1,000. That's doable, of course, as long as you have enough memory/CPU allocated to the Worker. For example, to actually run 1,000 Actors, you would need to calculate whether or not you need all Actors to be active at the same time (concurrency) or rely on multiplexing (Substrate's snapshot/warm state workflow)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9xifqlv90eptlbvovvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft9xifqlv90eptlbvovvk.png" alt=" " width="800" height="914"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It also depends on whether or not you choose to go with hardware-level isolation (microVM) or software-level isolation (gVisor). That math comes out to something like:&lt;/p&gt;

&lt;p&gt;gVisor == 256GiB of memory and 100 vCPUs.&lt;/p&gt;

&lt;p&gt;microVM == 2 TB memory and 1,000 vCPUs.&lt;/p&gt;

&lt;p&gt;Two numbers ultimately decide how many Actors fit on a Worker:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Workers capacity (hardware resources)&lt;/li&gt;
&lt;li&gt;The Actors size (you'll see that via the &lt;code&gt;resources.limits&lt;/code&gt; on the &lt;code&gt;ActorTemplate&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's get hands-on.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Port-forward locally to your atenet-router so you can reach it programmatically.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl port-forward -n ate-system svc/atenet-router 8000:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Re-use the images that were used to build out the &lt;code&gt;WorkerPool&lt;/code&gt; during installation of Substrate. You'll also see the &lt;code&gt;COUNTER_IMAGE&lt;/code&gt;, which is the image used to deploy the counter demo. This will be used in the next section when you deploy Actors.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;WORKER_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get workerpool counter -n ate-demo-counter -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.spec.workerImage}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;COUNTER_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl ate get actor-template counter -a ate-demo-counter -o json \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.containers[0].image'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"${WORKER_IMAGE}"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"${COUNTER_IMAGE}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create the new &lt;code&gt;WorkerPool&lt;/code&gt; with specific resource limits and requests.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Namespace&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate-packing&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;WorkerPool&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;packing&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate-packing&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;workload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;packing&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;workerImage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${WORKER_IMAGE}&lt;/span&gt;
  &lt;span class="na"&gt;sandboxClasses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gvisor&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"10"&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10Gi&lt;/span&gt;
      &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1000m&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;6Gi&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡&lt;/p&gt;

&lt;p&gt;Capacity comes from &lt;code&gt;limits&lt;/code&gt;. The &lt;code&gt;requests&lt;/code&gt; only tell the k8s Scheduler what to reserve on the node.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ensure the Workers are running.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate get workers -n ate-packing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the following, which showcases your original &lt;code&gt;WorkerPool&lt;/code&gt; when you install Substrate and the new &lt;code&gt;WorkerPool&lt;/code&gt;, which contains 1 replica (Worker/Pod). The reason why is to see that more than one Actor can, in fact, be scheduled on one Worker.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fge5h521lid108q1j8u1b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fge5h521lid108q1j8u1b.png" alt=" " width="745" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the Workers up, let's start deploying Actors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resizing Workers
&lt;/h3&gt;

&lt;p&gt;Capacity is read once when a Worker starts. To change it, you'll need to change the &lt;code&gt;WorkerPool&lt;/code&gt; limits. The Controller then rolls out a new Worker with new capacity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; a &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;kubectl ate get actors -a packing -o json &lt;span class="o"&gt;|&lt;/span&gt; jq -r \
    &lt;span class="s1"&gt;'.actors[] | select(.status.state == "ACTOR_STATE_RUNNING") | .metadata.name'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor &lt;span class="s2"&gt;"$a"&lt;/span&gt; -a packing
&lt;span class="k"&gt;done&lt;/span&gt;

kubectl patch workerpool packing -n ate-packing --type merge \
  -p &lt;span class="s1"&gt;'{"spec":{"template":{"resources":{"limits":{"cpu":"2","memory":"2Gi"},"requests":{"cpu":"250m","memory":"2Gi"}}}}}'&lt;/span&gt;
kubectl rollout status deployment/packing -n ate-packing
kubectl ate get workers -n ate-packing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running Multiple Actors In One Worker
&lt;/h2&gt;

&lt;p&gt;The goal of this blog post is to test and ensure that you can run more than one Actor within a Worker. This is important as the industry continues down the path of running agentic workloads in an efficient and performant fashion. Originally, many of the agentic runtimes would be a mapping of "one Agent to one Pod", but that doesn't scale well considering the amount of Agents that run in production in comparison to a standard workload.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkqfoxihs2such37uv3l1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkqfoxihs2such37uv3l1.gif" alt=" " width="760" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the Atespace (where Actors live; it's like a Namespace).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl ate create atespace packing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Ensure that your &lt;code&gt;WorkerPool&lt;/code&gt; is running the gVisor sandbox class.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get workerpool packing -n ate-packing -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.status.sandboxClasses}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create the &lt;code&gt;ActorTemplate&lt;/code&gt;. To ensure that the Actors land on the correct &lt;code&gt;WorkerPool&lt;/code&gt;, you'll see that &lt;code&gt;workerSelector.matchLabels.workload&lt;/code&gt; is used as the parameter and &lt;code&gt;packing&lt;/code&gt; as the value.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; size &lt;span class="k"&gt;in&lt;/span&gt; 256 512&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate create actor-template -f - &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF
metadata:
  atespace: packing
  name: mem-&lt;span class="nv"&gt;${size}&lt;/span&gt;
workerSelector:
  matchLabels:
    workload: packing
containers:
- name: counter
  image: &lt;span class="nv"&gt;${COUNTER_IMAGE}&lt;/span&gt;
  command:
  - /ko-app/counter
  wakeupProbe:
    httpGet:
      path: /readyz
      port: 80
resources:
  limits:
  - name: cpu
    quantity: 250m
  - name: memory
    quantity: &lt;span class="nv"&gt;${size}&lt;/span&gt;Mi
snapshotConfig:
  preferredFidelity: SNAPSHOT_FIDELITY_MEMORY
  storageLocation: gs://ate-snapshots/packing/
sandboxConfig:
  sandboxClass: gvisor
  configName: gvisor-default
EOF
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the one below showing that the templates have been created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhp8fjiebyceqtjrf2dem.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhp8fjiebyceqtjrf2dem.png" alt=" " width="506" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start and connect to the Actors so they get scheduled. You can also send a &lt;code&gt;curl&lt;/code&gt; to interact with them.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 9&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate create actor &lt;span class="s2"&gt;"a$i"&lt;/span&gt; -a packing --template mem-256
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 8&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  curl -s -X POST -H &lt;span class="s2"&gt;"ate-target-actor: packing/a$i"&lt;/span&gt; http://localhost:8000
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqtiayzpzezu6wa36ir3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqtiayzpzezu6wa36ir3n.png" alt=" " width="799" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You can also see the Actors within the "packing" &lt;code&gt;atespace&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate get actors -a packing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffvu25ithmyifd29ckeds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffvu25ithmyifd29ckeds.png" alt=" " width="800" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>agents</category>
      <category>architecture</category>
      <category>infrastructure</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Scaling Actors and Workers With HPA In Agent Substrate</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Thu, 15 Oct 2026 12:12:02 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/scaling-actors-and-workers-with-hpa-in-agent-substrate-1gfj</link>
      <guid>https://dev.to/thenjdevopsguy/scaling-actors-and-workers-with-hpa-in-agent-substrate-1gfj</guid>
      <description>&lt;p&gt;The number one rule of scaling is ensuring that you have more than enough resources readily available to consume, digest, and schedule what you need to run. In the case of agentic workloads, that's typically Agents. For example, is there enough memory to run multi-Actor Workers? Or do you need to scale Workers out to schedule Actors accordingly?&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn how to schedule and scale Actors (where Agents run) via Workers and WorkerPools for any number of Actors that need to run within your environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post from a hands-on perspective, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A cluster with Agent Substrate running (e.g., GKE or a local cluster like Kind).

&lt;ol&gt;
&lt;li&gt;Agentgateway set as the dataplane proxy for your &lt;code&gt;atenet-router&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Worker images built with your underlying isolation layer (e.g., gVisor).

&lt;ol&gt;
&lt;li&gt;You can build these images via the Agent Substrate repo (you need to clone it down) &lt;code&gt;./hack/run-tool.sh&lt;/code&gt; and see how to do it here.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Will You Be Deploying?
&lt;/h2&gt;

&lt;p&gt;Going through this blog post, you will be:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deploying Actors&lt;/li&gt;
&lt;li&gt;"Parking" an Actor until a Worker is ready to schedule it.&lt;/li&gt;
&lt;li&gt;Scaling out Workers so if you have, let's say 3 Actors but only 2 Workers, HPA can scale out the Worker (a Pod) to schedule the third Actor.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frow7ofzk6gejn9suzpcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frow7ofzk6gejn9suzpcq.png" alt=" " width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The goal here is to park Actors when there aren't enough Workers, or memory in the Workers, readily available to schedule an Actor. The Workers in this blog have a 1Gi memory limit, and each Actor asks for 768Mi. A second Actor needs 1536Mi, which means it won't fit. If anyone raises the WorkerPool memory or lowers the Template's, Actors will start sharing workers. Once a Worker is made available, the Actor can be automatically scheduled on said Worker so your Agent can run.&lt;/p&gt;

&lt;p&gt;To go through the hands-on portion of this blog post in the way that it is configured, you'll want to clone this repo as it has all of the scripts and HPA configurations to run the lab along with Step 1 and Step 2, which is building the images and deploying your Workers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F08ljbehuveh503g9dbwv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F08ljbehuveh503g9dbwv.png" alt=" " width="800" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying Actors
&lt;/h2&gt;

&lt;p&gt;The first step is deploying Actors. All Actors, when deployed, are automatically in a "suspended" state. Because they're in a suspended state, they aren't technically running, which is where the efficiency and overall performance of Agent Substrate come into play. Actors are only running when there is an active session to said Actor. That way, they aren't consuming resources (CPU/memory) for no reason.&lt;/p&gt;

&lt;p&gt;Actors sit in a "warm state", which means they don't take seconds to resume. That way, when you create a session to an Actor that's running an Agent, it won't feel like the Actor is in a cold state and takes forever to resume/respond to the request that you're sending to the Actor running an Agent.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deploy the Actors. The pool caps each worker at 1Gi of memory (&lt;code&gt;manifests/workerpool.yaml.tmpl&lt;/code&gt;), and the template asks for 768Mi per actor (&lt;code&gt;manifests/actortemplate.yaml.tmpl&lt;/code&gt;). The scheduler only places an actor where its memory still fits, so a second actor never does.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; 1 2 3 4 5 6&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate create actor &lt;span class="s2"&gt;"a$i"&lt;/span&gt; -a ate-lab-burst --template burst
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡&lt;/p&gt;

&lt;p&gt;the &lt;code&gt;burst&lt;/code&gt; template is what's created in &lt;code&gt;actortemplate.yaml.tmpl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;All six start in&amp;nbsp;&lt;code&gt;ACTOR_STATE_SUSPENDED&lt;/code&gt;. They exist only as records, plus the golden snapshot in GCS.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Confirm that the Actors are in a suspended state and in Agent Substrate.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get actors -a ate-lab-burst
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see an output similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F10jesjayz1qcfm2pzufj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F10jesjayz1qcfm2pzufj.png" alt=" " width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you're going through the rest of this blog post, an important note to keep in mind is that because six Actors were deployed and there are two Workers, there's a 3:1 ratio here. That means two Actors can be scheduled, but four cannot and therefore sit in a "parked" state until a Worker is available.&lt;/p&gt;

&lt;h2&gt;
  
  
  Park and Schedule An Actor
&lt;/h2&gt;

&lt;p&gt;With the Actors deployed, let's resume two of the Actors, and then try a third, which will sit in a parked state until a Worker becomes readily available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9fnqxvsysyo83lg7ovl1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9fnqxvsysyo83lg7ovl1.png" alt=" " width="800" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Port-forward the router so it's open and accepting requests (for when a client or something like &lt;code&gt;curl&lt;/code&gt; needs to reach it).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl -n ate-system port-forward svc/atenet-router 8000:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Fill both Workers with Actors.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -H &lt;span class="s2"&gt;"ate-target-actor: ate-lab-burst/a1"&lt;/span&gt; http://localhost:8000
curl -s -H &lt;span class="s2"&gt;"ate-target-actor: ate-lab-burst/a2"&lt;/span&gt; http://localhost:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Check and confirm that both Workers got assigned an Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate get workers -n ate-lab-burst
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME                                   POOL    STATE                 ACTORS   CPU      MEMORY      POD                                    AGE
cc852e96-6035-47a1-96e9-1b85d2b47c95   burst   WORKER_STATE_ACTIVE   1/1000   0/500m   768Mi/1Gi   ate-lab-burst/burst-6ff589448f-t26t7   20m
43210b1e-2a85-496c-96e9-497575d4e200   burst   WORKER_STATE_ACTIVE   1/1000   0/500m   768Mi/1Gi   ate-lab-burst/burst-6ff589448f-t7gm6   20m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Try assigning a third Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -w &lt;span class="s1"&gt;'-&amp;gt; HTTP %{http_code} in %{time_total}s\n'&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"ate-target-actor: ate-lab-burst/a3"&lt;/span&gt; http://localhost:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll get a "request timed out" with a 504. The reason why is that there isn't enough memory on either Worker to schedule the third Actor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdf9ocszsxybapb6rkp06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdf9ocszsxybapb6rkp06.png" alt=" " width="567" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Suspend Actor 1 and then run the &lt;code&gt;curl&lt;/code&gt; again.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor a1 -a ate-lab-burst
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -w &lt;span class="s1"&gt;'-&amp;gt; HTTP %{http_code} in %{time_total}s\n'&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"ate-target-actor: ate-lab-burst/a3"&lt;/span&gt; http://localhost:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see that Actor 3 can now be scheduled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flr3rlilcb8dp4jl9dha9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flr3rlilcb8dp4jl9dha9.png" alt=" " width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Add HPA For WorkerPools
&lt;/h2&gt;

&lt;p&gt;In the previous section, you saw that because there are two Workers available within the WorkerPool, only 2/3 of the Actors could be scheduled on the Worker until a Worker freed up.&lt;/p&gt;

&lt;p&gt;As you read in the &lt;strong&gt;What Will You Be Deploying?&lt;/strong&gt; section, multiple Actors CAN be scheduled on one Worker as long as there's enough memory to support it. The scenario we want HPA for WorkerPools is when the Worker runs out of memory and therefore a new Worker (Pod/replica) needs to be created.&lt;/p&gt;

&lt;p&gt;Tldr; Where HPA comes into play is scaling out an Actor to another Worker (or as many Workers as are needed based on how many Actors are waiting to be unparked).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fetizyvbxe679fumecwbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fetizyvbxe679fumecwbb.png" alt=" " width="800" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💡 Because you created six Actors in the &lt;strong&gt;Deploying Actors&lt;/strong&gt; section and the HPA config allows up to 10 replicas, all six Actors will be deployed onto the Workers as there will now be more Workers available because the replica count in the HPA config goes up to ten.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the &lt;code&gt;burst&lt;/code&gt; script to wake up all six Actors
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./scripts/burst.sh -m hold -d 120
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see 504s (timeouts) for the 4 Actors that aren't scheduled on Workers as they aren't scheduled and therefore, aren't running.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn6gsx3yeepr1kya3lr12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn6gsx3yeepr1kya3lr12.png" alt=" " width="741" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In another terminal, scale your WorkerPool to 6 replicas
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl -n ate-lab-burst scale workerpool burst --replicas=6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Go back to the first terminal and you'll see the scale start to occur (from 2/2 to 6/6). This shows that all six Actors are now up and running with successful 200's.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3quttsg9uf02qhd8gth9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3quttsg9uf02qhd8gth9.png" alt=" " width="543" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This proves out that scaling the Workers officially worked!&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Scale becomes increasingly important in the world of agentic because it impacts so many areas. It's not just one app that impacts a department or a particular functionality of an app that impacts a customer. If an Agent is down, it can potentially impact the entire organization. That's why ensuring that scale can be properly implemented across Agents isn't just about the tech teams; it's everyone from engineering to marketing to HR and all teams that are incorporating AI into daily workflows.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>cloud</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>How To Implement the AgentgatewayModel Object In Agentgateway</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sun, 04 Oct 2026 13:42:43 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/how-to-implement-the-agentgatewaymodel-object-in-agentgateway-534</link>
      <guid>https://dev.to/thenjdevopsguy/how-to-implement-the-agentgatewaymodel-object-in-agentgateway-534</guid>
      <description>&lt;p&gt;Knowing what LLM you're routing to, whether or not failover for more expensive tasks exists, what LLMs are available, and policy enforcement/implementation for the people accessing LLMs are critical pathways to properly implementing agentic workloads in production.&lt;/p&gt;

&lt;p&gt;Luckily, there are a few key ways to do it in agentgateway. One with less YAML, and one with routing to everything from LLMs to MCP Servers and a2a endpoints.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn about the &lt;code&gt;AgentgatewayBackend&lt;/code&gt; object, the &lt;code&gt;AgentgatewayModel&lt;/code&gt; object, and how to implement the &lt;code&gt;AgentgatewayModel&lt;/code&gt; object in agentgateway OSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post from a hands-on perspective, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A k8s cluster (local is fine).&lt;/li&gt;
&lt;li&gt;Agentgateway OSS installed, and you can learn how to do so here.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The hands-on portion uses Anthropic as the LLM provider, but if you prefer to use another, you can see the available providers via agentgateway here.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is AgentgatewayModel?
&lt;/h2&gt;

&lt;p&gt;When using the &lt;code&gt;AgentgatewayModel&lt;/code&gt; object, you have the ability to interact with the LLM directly. You don't have to set up separate routes for interacting with the LLM or use a policy oject to set policy enforcement for LLM requests (rate limits, failover, governance, etc.). Instead, you define it all at the &lt;code&gt;AgentgatewayModel&lt;/code&gt; object level. Because of this, you have far less YAML/JSON to worry about when creating and configuring your path to LLMs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl5cvae43hkbx8s32mghv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl5cvae43hkbx8s32mghv.gif" alt=" " width="800" height="1191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two other key implementations are the &lt;code&gt;virtualModel&lt;/code&gt; parameter and how public Models are listed. With the &lt;code&gt;Public&lt;/code&gt; component, Models are listed in discovery and can be requested directly. The Virtual Models component gives you weight/percentage splits between LLMs and failover for priority groups.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does It Differ from AgentgatewayBackend?
&lt;/h2&gt;

&lt;p&gt;There are a few key differences between &lt;code&gt;AgentgatewayBackend&lt;/code&gt; and &lt;code&gt;AgentgatewayModel&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;AgentgatewayModel&lt;/code&gt; is used to route traffic to an LLM (no other backends like static, a2a, mcp, etc.).&lt;/li&gt;
&lt;li&gt;It has its own &lt;code&gt;parentRefs&lt;/code&gt;, which means it points straight to the Gateway (no &lt;code&gt;HTTPRoute&lt;/code&gt; needed).&lt;/li&gt;
&lt;li&gt;Policies are set on the LLM itself (no &lt;code&gt;AgentgatewayPolicy&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0afl4f9tgcz1qecfa3hf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0afl4f9tgcz1qecfa3hf.jpg" alt=" " width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You still want to use an &lt;code&gt;AgentgatewayBackend&lt;/code&gt; when you need to route to anything that isn't an LLM and path-based routing for things like header matching/filters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using AgentgatewayModel
&lt;/h2&gt;

&lt;p&gt;Now that you know the "how" and "why" behind when to use &lt;code&gt;AgentgatewayModel&lt;/code&gt;, let's see it in action. You will see three configs and put them to the test:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A standard Gateway object to ensure it's working as expected.&lt;/li&gt;
&lt;li&gt;Failover/weighted routing&lt;/li&gt;
&lt;li&gt;Policies&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Level 100 Config
&lt;/h3&gt;

&lt;p&gt;The first configuration is just to see the LLM path/request via your gateway work in general. To do this, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A new Namespace called &lt;code&gt;llm-models&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A Secret with your Anthropic API key in the &lt;code&gt;llm-models&lt;/code&gt; Namespace.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create the following to have an object that calls to &lt;code&gt;claude-haiku-4-5&lt;/code&gt; and your new Gateway.&lt;/p&gt;

&lt;p&gt;💡 Typically, you're probably used to manually setting the LLM name. With &lt;code&gt;AgentgatewayModel&lt;/code&gt;, it's set via the &lt;code&gt;metadata.name&lt;/code&gt; parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayModel&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;claude-haiku-4-5&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-models&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-gateway&lt;/span&gt;
    &lt;span class="na"&gt;sectionName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Anthropic&lt;/span&gt;
  &lt;span class="na"&gt;policies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;secretRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;anthropic-key&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-gateway&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-models&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;gatewayClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway&lt;/span&gt;
  &lt;span class="na"&gt;listeners&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm&lt;/span&gt;
    &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTP&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
    &lt;span class="na"&gt;allowedRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;namespaces&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Same&lt;/span&gt;
      &lt;span class="na"&gt;kinds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev&lt;/span&gt;
        &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayModel&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Port-forward the &lt;code&gt;Gateway&lt;/code&gt; object so you can reach it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl port-forward -n llm-models svc/llm-gateway 8080:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following to see the list of available LLMs. This alone is an important implementation as a lot of organizations want the ability to see what models are available within a gateway path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s localhost:8080/v1/models &lt;span class="o"&gt;|&lt;/span&gt; jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc9sn2gzf671v4upai62b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc9sn2gzf671v4upai62b.png" width="361" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, prompt it to ensure its working as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s localhost:8080/v1/chat/completions -H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; -d &lt;span class="s1"&gt;'{"model":"claude-haiku-4-5","messages":[{"role":"user","content":"Say hi"}]}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1drubzz22sxyclft93ep.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1drubzz22sxyclft93ep.png" width="437" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Failover
&lt;/h3&gt;

&lt;p&gt;The below will prove out that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first request returns a 401 due to a bad API key (the &lt;code&gt;secretRef&lt;/code&gt; points to a fake key).&lt;/li&gt;
&lt;li&gt;Because of the failover, requests 2 and 3 will return a 200.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create the bad key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create secret generic bad-key -n llm-models --from-literal=Authorization=sk-ant-invalid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply the new &lt;code&gt;AgentgatewayModel&lt;/code&gt; objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayModel&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;failover-primary&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-models&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-gateway&lt;/span&gt;
    &lt;span class="na"&gt;sectionName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm&lt;/span&gt;
  &lt;span class="na"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Internal&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Anthropic&lt;/span&gt;
  &lt;span class="na"&gt;policies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;secretRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bad-key&lt;/span&gt;
    &lt;span class="na"&gt;transformations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;model&lt;/span&gt;
      &lt;span class="na"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'"claude-sonnet-4-5"'&lt;/span&gt;
    &lt;span class="na"&gt;health&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;unhealthyCondition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'response.code &amp;gt;= 400'&lt;/span&gt;
      &lt;span class="na"&gt;eviction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;consecutiveFailures&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;60s&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayModel&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;failover-fallback&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-models&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-gateway&lt;/span&gt;
    &lt;span class="na"&gt;sectionName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm&lt;/span&gt;
  &lt;span class="na"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Internal&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Anthropic&lt;/span&gt;
  &lt;span class="na"&gt;policies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;secretRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;anthropic-key&lt;/span&gt;
    &lt;span class="na"&gt;transformations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;model&lt;/span&gt;
      &lt;span class="na"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'"claude-haiku-4-5"'&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayModel&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;resilient-test&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-models&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-gateway&lt;/span&gt;
    &lt;span class="na"&gt;sectionName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm&lt;/span&gt;
  &lt;span class="na"&gt;virtualModel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;failover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;modelRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;failover-primary&lt;/span&gt;
        &lt;span class="na"&gt;priority&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;modelRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;failover-fallback&lt;/span&gt;
        &lt;span class="na"&gt;priority&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following &lt;code&gt;curl&lt;/code&gt; to test it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; 1 2 3&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  curl -s -w &lt;span class="s1"&gt;'  [%{http_code}]\n'&lt;/span&gt; localhost:8080/v1/chat/completions -H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; \
    -d &lt;span class="s1"&gt;'{"model":"resilient-test","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; tail -c 200
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see that the first call gives you a 401.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"event_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"invalid_request_error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"API key is invalid."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="s2"&gt;":{"&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;Hello&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt; &lt;span class="n"&gt;How&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;assistant&lt;/span&gt;&lt;span class="s2"&gt;"},"&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="s2"&gt;":0,"&lt;/span&gt;&lt;span class="n"&gt;finish_reason&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="s2"&gt;"}],"&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;msg_011CfhHS8ey2oiRF4fUP9x8s&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="n"&gt;created&lt;/span&gt;&lt;span class="s2"&gt;":1791120881,"&lt;/span&gt;&lt;span class="n"&gt;object&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completion&lt;/span&gt;&lt;span class="s2"&gt;"}  [200]
{"&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="s2"&gt;":{"&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="n"&gt;Hello&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt; &lt;span class="err"&gt;👋\&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;nHow&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;assistant&lt;/span&gt;&lt;span class="s2"&gt;"},"&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="s2"&gt;":0,"&lt;/span&gt;&lt;span class="n"&gt;finish_reason&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="s2"&gt;"}],"&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;msg_011CfhHSB2qXibWjAoFZvwY7&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="n"&gt;created&lt;/span&gt;&lt;span class="s2"&gt;":1791120882,"&lt;/span&gt;&lt;span class="n"&gt;object&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completion&lt;/span&gt;&lt;span class="s2"&gt;"}  [200]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Policy
&lt;/h3&gt;

&lt;p&gt;Implementing a policy within the &lt;code&gt;AgentgatewayModel&lt;/code&gt; object, you have the ability to specify both CEL and prompt guards.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayModel&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;claude-haiku-4-5&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-models&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm-gateway&lt;/span&gt;
    &lt;span class="na"&gt;sectionName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;llm&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Anthropic&lt;/span&gt;
  &lt;span class="na"&gt;policies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;secretRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;anthropic-key&lt;/span&gt;
    &lt;span class="na"&gt;authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Allow&lt;/span&gt;
      &lt;span class="na"&gt;policy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;matchExpressions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'request.headers["x-team"] in ["platform", "data-science"]'&lt;/span&gt;
    &lt;span class="na"&gt;promptGuard&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;regex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;builtins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;Ssn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;CreditCard&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
          &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Reject&lt;/span&gt;
        &lt;span class="na"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt;
          &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Request blocked: contains sensitive data (SSN/credit card)."&lt;/span&gt;
      &lt;span class="na"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;regex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;builtins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
          &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Mask&lt;/span&gt;
    &lt;span class="na"&gt;transformations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;max_tokens&lt;/span&gt;
      &lt;span class="na"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'256'&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;x-served-by-model&lt;/span&gt;
          &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;claude-haiku-4-5&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following, which ensures the &lt;code&gt;x-team&lt;/code&gt; header is passed for the CEL implementation via the &lt;code&gt;curl&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -si localhost:8080/v1/chat/completions -H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; -H &lt;span class="s1"&gt;'x-team: platform'&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"claude-haiku-4-5","messages":[{"role":"user","content":"Say hi"}]}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -i &lt;span class="s1"&gt;'x-served-by-model\|HTTP/'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see that the request goes through and has a proper output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="no"&gt;OK&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;served&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;claude&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;haiku&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if you try to do a &lt;code&gt;curl&lt;/code&gt; with an SSN, it'll fail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s localhost:8080/v1/chat/completions -H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; -H &lt;span class="s1"&gt;'x-team: platform'&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"claude-haiku-4-5","messages":[{"role":"user","content":"My SSN is 123-45-6789"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request blocked: contains sensitive data (SSN/credit card).%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;With how quickly AI moves and especially how traffic needs to be routed to LLMs, it's great to have options. If you want something that's "baked in" with policies, routing, and failover into one object, you have an option. If you need header-based routing, filters, and rewrites based on how you want to route said traffic, you have an option for that as well.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>kubernetes</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Deploying an Agent Substrate Actor After ActorTemplate Left Kubernetes</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sat, 05 Sep 2026 16:22:48 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/deploying-an-agent-substrate-actor-after-actortemplate-left-kubernetes-mcn</link>
      <guid>https://dev.to/thenjdevopsguy/deploying-an-agent-substrate-actor-after-actortemplate-left-kubernetes-mcn</guid>
      <description>&lt;p&gt;As of 09/02/2026, the &lt;code&gt;ActorTemplate&lt;/code&gt; object no longer exists. It was created, as the name suggests, to be the template/golden template that Actors use to deploy with particular settings and configurations for it to run as expected.&lt;/p&gt;

&lt;p&gt;In this quickstart blog post, you'll see how to deploy Actors without an &lt;code&gt;ActorTemplate&lt;/code&gt; and also understand the reasoning behind this change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post in a hands-on fashion, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GKE cluster or a raw k8s cluster (microk8s, kubeadm, etc.) running locally so you have direct access to the API server.&lt;/li&gt;
&lt;li&gt;Agent Substrate installed. You can learn how to do so here.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you don't have a cluster, that's totally fine. You can still follow along from a theoretical standpoint and implement later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;The primary reason for this was that it was decided that the &lt;code&gt;ActorTemplate&lt;/code&gt; object should be an &lt;code&gt;ateapi&lt;/code&gt; resource, not a Kubernetes object/CRD. When it was running as a k8s object, it leaked the wrong identity, naming, lifecycle, and auth into the public API (same conventions as any other k8s object - kubectl apply, namespaces, CRD conventions, etc.), so CLI, SaaS, and gRPC clients could not share one surface and the schema could not evolve independently of Kubernetes. Because Actors are an &lt;code&gt;ateapi&lt;/code&gt; object, it made sense to have the templates for said Actors as an &lt;code&gt;ateapi&lt;/code&gt; object as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fukav0lr4hmcrhgtee8ju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fukav0lr4hmcrhgtee8ju.png" width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Kubernetes and What's Ateapi
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;ate-api-server&lt;/code&gt; now owns templates through:&lt;/p&gt;

&lt;h2&gt;
  
  
  - &lt;code&gt;ateapi.Control&lt;/code&gt;
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- `CreateActorTemplate`
- `GetActorTemplate`
- `ListActorTemplates`
- `DeleteActorTemplate`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Along with the &lt;code&gt;Actor&lt;/code&gt;, &lt;code&gt;Worker&lt;/code&gt;, and &lt;code&gt;atespace&lt;/code&gt; objects&lt;/p&gt;

&lt;p&gt;However, there are still objects/CRDs that exist in Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48n9gsnylz8g0j58pklt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48n9gsnylz8g0j58pklt.png" alt=" " width="450" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the core knowledge of what exists and what has changed, let's now dive in from a hands-on perspective to deploy the resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prepare The Template
&lt;/h2&gt;

&lt;p&gt;The Template will now be a YAML configuration that is fed into the &lt;code&gt;ateapi&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Below is an example configuration that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a new template called &lt;code&gt;counter&lt;/code&gt; in the &lt;code&gt;ate-demo-counter&lt;/code&gt; namespace.&lt;/li&gt;
&lt;li&gt;Creates a Worker Selector so Actors from this template may only schedule onto &lt;code&gt;WorkerPools&lt;/code&gt; whose &lt;code&gt;metadata.labels&lt;/code&gt; include &lt;code&gt;workload: counter&lt;/code&gt;. It is pool selection, same idea as a Pod nodeSelector.&lt;/li&gt;
&lt;li&gt;Specifies the container along with the ready probes.&lt;/li&gt;
&lt;li&gt;Volume mounts for persistent data.&lt;/li&gt;
&lt;li&gt;Resource limits.&lt;/li&gt;
&lt;li&gt;Snapshot configurations.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;atespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate-demo-counter&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;counter&lt;/span&gt;
&lt;span class="na"&gt;workerSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;workload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;counter&lt;/span&gt;
&lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;counter&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;digest-pinned image&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/ko-app/counter&lt;/span&gt;
  &lt;span class="na"&gt;readyz&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/readyz&lt;/span&gt;
      &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
  &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
    &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/home/counter&lt;/span&gt;
&lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cpu&lt;/span&gt;
    &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;memory&lt;/span&gt;
    &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512Mi&lt;/span&gt;
&lt;span class="na"&gt;snapshotsConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;onPause&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SNAPSHOT_CONTENT_SCOPE_FULL&lt;/span&gt;
  &lt;span class="na"&gt;onCommit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SNAPSHOT_CONTENT_SCOPE_FULL&lt;/span&gt;
  &lt;span class="na"&gt;storageLocation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gs://${BUCKET_NAME}/ate-demo-counter/&lt;/span&gt;
&lt;span class="na"&gt;sandboxConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sandboxClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SANDBOX_CLASS_GVISOR&lt;/span&gt;
  &lt;span class="na"&gt;configName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gvisor-default&lt;/span&gt;
&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
  &lt;span class="na"&gt;durableDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the configuration like the one above is defined, you would save it and then create the template.&lt;/p&gt;

&lt;p&gt;For example, if you saved it as &lt;code&gt;counter-template.yaml&lt;/code&gt;, you would create the &lt;code&gt;atespace&lt;/code&gt; and then the template within the &lt;code&gt;atespace&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate create atespace ate-demo-counter
kubectl ate create actor-template -f counter-template.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create An Actor
&lt;/h2&gt;

&lt;p&gt;With the template created, you can now create an Actor.&lt;/p&gt;

&lt;p&gt;The actor ID is a &lt;code&gt;DNS-1123&lt;/code&gt; label. &lt;code&gt;--template-ref&lt;/code&gt; is the template name that exists in the &lt;code&gt;atespace&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Actor creation looks like the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate create actor my-counter-1 \
  --atespace ate-demo-counter \
  --template-ref counter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8sttrl8vpilnhb2hu5yi.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8sttrl8vpilnhb2hu5yi.gif" alt=" " width="760" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Agent Substrate is a fast-moving project, and for good reason - because the AI world is moving at a rapid pace, probably faster than any other technological evolution. Because of that, the project needs to change what makes the most sense for how engineers will use Substrate. Changing the Template to the Substrate API instead of relying on the Kubernetes API is a great implementation to "split the responsibility".&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>kubernetes</category>
      <category>cloud</category>
    </item>
    <item>
      <title>GPUs For Actors In Agent Substrate</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Tue, 01 Sep 2026 13:18:32 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/gpus-for-actors-in-agent-substrate-11p7</link>
      <guid>https://dev.to/thenjdevopsguy/gpus-for-actors-in-agent-substrate-11p7</guid>
      <description>&lt;p&gt;The increase in cost of GPUs and AI is hitting an all-time high, so much so that it's hard to even get GPU usage approved within a public cloud environment. Because of that, the ability to splice/share GPUs across workloads that need GPUs (apps, Agents) is a necessity not only for cost savings, but for hardware/resource savings as GPUs aren't an unlimited resource (especially nowadays).&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn how to implement CUDA (NVIDIA's parallel processing) inside an Agent Substrate Actor and see how many intermittent GPU workloads can take turns using a smaller pool of GPU-backed Substrate Workers.&lt;/p&gt;

&lt;p&gt;💡How Agents work today (tool calls, planning, loops, etc.) are CPU-centric tasks. That means the majority of the time, you won't see an Agent that needs a GPU. However, there are a few edge cases (neural-network math that's local, the LLM is in-process where the GPU is for the LLM, but it lives inside the Agent process, a tool the Agent runs is a GPU job like local image/vid gen) where an Agent using a GPU makes sense. This blog, however, uses a standard HTTP app inside of the Actor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post from a hands-on perspective, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GKE or local k8s cluster (Kind, minikube, microk8s, etc.) as the &lt;code&gt;PodCertificate&lt;/code&gt; API needs the ability to be enabled on the k8s API server.&lt;/li&gt;
&lt;li&gt;At least one Worker Node with a GPU attached.&lt;/li&gt;
&lt;li&gt;Agent Substrate repo cloned locally.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;KO_DOCKER_REPO&lt;/code&gt; and &lt;code&gt;BUCKET_NAME&lt;/code&gt; from your Substrate env file (found in the repo from step 3 that you can edit).&lt;/li&gt;
&lt;li&gt;Clone this repo and go to &lt;code&gt;substrate/optimization/gpu-backed-actors&lt;/code&gt; to see what you're deploying and you'll need it to build the images later.&lt;/li&gt;
&lt;li&gt;Docker installed to build images.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Need For Extending Your GPU
&lt;/h2&gt;

&lt;p&gt;GPU splicing isn't new. With the NVIDIA Operator, we've been able to do that within Kubernetes for quite a while.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu0lecpj9sqrwqc90zr1t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu0lecpj9sqrwqc90zr1t.png" alt=" " width="800" height="718"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ConfigMap&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;time-slicing-config&lt;/span&gt;
&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;any&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;
    &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
    &lt;span class="na"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;migStrategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;none&lt;/span&gt;
    &lt;span class="na"&gt;sharing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;timeSlicing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;renameByDefault&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
        &lt;span class="na"&gt;failRequestsGreaterThanOne&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
        &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nvidia.com/gpu&lt;/span&gt;
            &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above shows that the NVIDIA GPU is deployed on a Worker Node within your k8s cluster and up to four (4) Pods can request a "piece" of the one GPU.&lt;/p&gt;

&lt;p&gt;You'd do that by putting a parameter like this within your Pods Manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;nvidia.com/gpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of splicing per Pod, you can splice per Actor (an Agent or HTTP app runs inside an Actor), which saves hardware resources and therefore cost because multiple Actors can run in one Worker Pod.&lt;/p&gt;

&lt;p&gt;💡As it stands right now, one Actor can run at a time within a Worker, which means the GPU is being used by said Actor.&lt;/p&gt;

&lt;p&gt;In the next section, you'll see how to ensure an Actor can use a NVIDIA GPU.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cluster Check
&lt;/h2&gt;

&lt;p&gt;A Substrate Actor can use a GPU the same way a Pod does, which is by putting &lt;code&gt;nvidia.com/gpu&lt;/code&gt; on the Worker/WorkerPool. There is no GPU field on &lt;code&gt;ActorTemplate&lt;/code&gt;. Instead, Substrate passes the assigned device into every container in the Actor.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Source your cluster and ensure Substrate is running.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; /path/to/substrate/.ate-dev-env.sh
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/path/to/substrate

kubectl get pods -n ate-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Check for the default sandbox configuration on your cluster.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get sandboxconfig gvisor-default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Confirm a NVIDIA GPU is on your cluster.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get nodes -o json &lt;span class="o"&gt;|&lt;/span&gt; jq -r \
  &lt;span class="s1"&gt;'["NAME","GPU","GKE_ACCEL","PRODUCT"],
   (.items[] | [
     .metadata.name,
     (.status.allocatable["nvidia.com/gpu"] // "-"),
     (.metadata.labels["cloud.google.com/gke-accelerator"] // "-"),
     (.metadata.labels["nvidia.com/gpu.product"] // "-")
   ]) | @tsv'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; column -t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsy8a7442bmzxb9mhvb31.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsy8a7442bmzxb9mhvb31.png" width="800" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section, you'll implement an Actor with a usable NVIDIA GPU.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement A GPU-Based Actor
&lt;/h2&gt;

&lt;p&gt;At the time of writing this, only gVisor (software-level isolation) based Actors can support GPUs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CRD rule on WorkerPool:

nvidia.com/gpu is only supported when sandboxClass is 'gvisor'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The source of this is via the kubebuilder CEL marker on &lt;code&gt;WorkerPoolSpec&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Because of that, you will have to ensure that you have gVisor enabled on your cluster running Substrate.&lt;/p&gt;

&lt;p&gt;💡The default &lt;code&gt;sandboxClass&lt;/code&gt; is gVisor, so if you didn't specify microVM during installation, you're good to go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F97ponz13du2c4h33lhch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F97ponz13du2c4h33lhch.png" alt=" " width="800" height="777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Build Images
&lt;/h3&gt;

&lt;p&gt;The images in this step are for the next step, but let's break down the "why" in terms of why we need them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The default worker is &lt;code&gt;gcr.io/distroless/static-debian13&lt;/code&gt;. It cannot exec nvidia-ctk, so it cannot inject a GPU into the sandbox.&lt;/li&gt;
&lt;li&gt;Substrate does not ship a GPU actor. &lt;code&gt;workload/&lt;/code&gt; Which you can find here, is the Actors application (it's a Go app) that calls out to the GPU. It runs nvidia-smi inside the Actor as a child process.&lt;/li&gt;
&lt;li&gt;Build the ateom gVisor GPU image:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ATEOM_GPU_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;
  &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"$SUBSTRATE_DIR"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
  &lt;span class="nv"&gt;KO_DOCKER_REPO&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$KO_DOCKER_REPO"&lt;/span&gt; \
  &lt;span class="nv"&gt;KO_DEFAULTPLATFORMS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;linux/amd64 \
  &lt;span class="nv"&gt;KO_DEFAULTBASEIMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;debian:stable-slim \
  ./hack/run-tool.sh ko build ./cmd/ateom-gvisor
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$ATEOM_GPU_IMAGE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Build an image that an &lt;code&gt;ActorTemplate&lt;/code&gt; can use, which is used as a golden image to deploy an Actor with GPU needs.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; agentic-demo-repo/substrate/optimization/gpu-backed-actors/workload

docker buildx build \
  --platform linux/amd64 \
  --push \
  --provenance=false \
  --metadata-file /tmp/gpu-agent.json \
  --tag &lt;span class="s2"&gt;"${KO_DOCKER_REPO}/gpu-actor-workload:gpu-agent"&lt;/span&gt; \
  workload/

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GPU_WORKLOAD_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${KO_DOCKER_REPO}/gpu-actor-workload@$(jq -er '."&lt;/span&gt;containerimage.digest&lt;span class="s2"&gt;"' /tmp/gpu-agent.json)"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$GPU_WORKLOAD_IMAGE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Capture your storage/snapshot location to be used later in &lt;code&gt;ActorTemplate&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SNAPSHOT_LOCATION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gs://${BUCKET_NAME}/ate-demo-gpu/"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ActorTemplate and WorkerPool
&lt;/h3&gt;

&lt;p&gt;With the proper images built for both the &lt;code&gt;WorkerPool&lt;/code&gt; to have the ability to inject GPUs and the GPU-based image so the Actor uses an image that requires a GPU for the workload to run, let's deploy the resources.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;WorkerPool&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;workerImage` is the glibc ateom so nvidia-ctk (CLI for the NVIDIA Container Toolkit, which is used to configure container runtimes and manage GPU support for containers) can run.

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;nvidia.com/gpu: "1"&lt;/code&gt; in requests and limits is what injects the GPU into the sandbox.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`yaml&lt;br&gt;
kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;br&gt;
apiVersion: v1&lt;br&gt;
kind: Namespace&lt;br&gt;
metadata:&lt;br&gt;
  name: ate-demo-gpu&lt;br&gt;
  labels:&lt;/p&gt;

&lt;h2&gt;
  
  
      gpu-backed-actors-demo: "true"
&lt;/h2&gt;

&lt;p&gt;apiVersion: ate.dev/v1alpha1&lt;br&gt;
kind: WorkerPool&lt;br&gt;
metadata:&lt;br&gt;
  name: gpu-workers&lt;br&gt;
  namespace: ate-demo-gpu&lt;br&gt;
  labels:&lt;br&gt;
    workload: gpu&lt;br&gt;
spec:&lt;br&gt;
  replicas: 1&lt;br&gt;
  sandboxClass: gvisor&lt;br&gt;
  workerImage: ${ATEOM_GPU_IMAGE}&lt;br&gt;
  template:&lt;br&gt;
    tolerations:&lt;br&gt;
    - key: nvidia.com/gpu&lt;br&gt;
      operator: Exists&lt;br&gt;
      effect: NoSchedule&lt;br&gt;
    resources:&lt;br&gt;
      requests:&lt;br&gt;
        cpu: 500m&lt;br&gt;
        memory: 2Gi&lt;br&gt;
        nvidia.com/gpu: "1"&lt;br&gt;
      limits:&lt;br&gt;
        cpu: "2"&lt;br&gt;
        memory: 4Gi&lt;br&gt;
        nvidia.com/gpu: "1"&lt;br&gt;
EOF&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the &lt;code&gt;ActorTemplate&lt;/code&gt;, which is the golden image/template that an Actor uses as a blueprint when it's created. Notice that it's using the GPU workload image.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;💡There is no GPU field on the template. The GPU comes from the &lt;code&gt;WorkerPool&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`yaml&lt;br&gt;
kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;br&gt;
apiVersion: ate.dev/v1alpha1&lt;br&gt;
kind: ActorTemplate&lt;br&gt;
metadata:&lt;br&gt;
  name: gpu-app&lt;br&gt;
  namespace: ate-demo-gpu&lt;br&gt;
spec:&lt;br&gt;
  sandboxClass: gvisor&lt;br&gt;
  workerSelector:&lt;br&gt;
    matchLabels:&lt;br&gt;
      workload: gpu&lt;br&gt;
  containers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;name: gpu-app
image: ${GPU_WORKLOAD_IMAGE}
readyz:
  httpGet:
    path: /readyz
    port: 80
resources:
limits:
  cpu: "1"
  memory: 2Gi
snapshotsConfig:
location: ${SNAPSHOT_LOCATION}
onPause: Full
onCommit: Full
EOF
`&lt;code&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create Actors
&lt;/h3&gt;

&lt;p&gt;With the &lt;code&gt;WorkerPool&lt;/code&gt; where the Actor runs and the Actor's golden image/template/blueprint created, you can now create the Actor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;shell&lt;br&gt;
kubectl ate create atespace gpu-demo&lt;br&gt;
kubectl ate create actor gpu-1 --atespace gpu-demo --template ate-demo-gpu/gpu-agent&lt;br&gt;
kubectl ate resume actor gpu-1 --atespace gpu-demo --boot&lt;br&gt;
kubectl ate logs actors gpu-1 --atespace gpu-demo&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnnq25zwrsx72no8j6g93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnnq25zwrsx72no8j6g93.png" alt=" " width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can test the Actor to ensure that it's working as expected:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`shell&lt;br&gt;
kubectl -n ate-system port-forward svc/atenet-router 8000:80&lt;/p&gt;

&lt;p&gt;curl -sS \&lt;br&gt;
  -H 'Host: gpu-1.gpu-demo.actors.resources.substrate.ate.dev' \&lt;br&gt;
  &lt;a href="http://localhost:8000/gpu" rel="noopener noreferrer"&gt;http://localhost:8000/gpu&lt;/a&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0mkuzt9bwwzou52p3wgy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0mkuzt9bwwzou52p3wgy.png" alt=" " width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"No running processes found" is expected. &lt;code&gt;GET /gpu&lt;/code&gt; runs &lt;code&gt;nvidia-smi&lt;/code&gt; as a child and then exits. The Processes table only lists jobs that currently hold GPU memory (a CUDA context).&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>kubernetes</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Why You Need Rate Limiting for MCP Servers (And How to Do It)</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sat, 15 Aug 2026 14:53:58 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/why-you-need-rate-limiting-for-mcp-servers-and-how-to-do-it-1l7p</link>
      <guid>https://dev.to/thenjdevopsguy/why-you-need-rate-limiting-for-mcp-servers-and-how-to-do-it-1l7p</guid>
      <description>&lt;p&gt;Without proper controls for how many times an Agent/LLM can hit an MCP Server, you open yourself up to potential DOS attacks, memory hogging, insane API bills, and server/system overload. Luckily, this can be mitigated quickly by rate-limiting the number of requests an Agent can make to an MCP Server.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn how to implement rate limiting for MCP using agentgateway.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post from a hands-on perspective, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A k8s cluster (local with something like Kind or Minikube is perfect).&lt;/li&gt;
&lt;li&gt;Agentgateway installed.&lt;/li&gt;
&lt;li&gt;A GitHub account.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Rate Limiting in a Nutshell
&lt;/h2&gt;

&lt;p&gt;If you think about what a memory leak in an application is conceptually, it's a bug in the software that effectively allows the application to continue to consume RAM/memory to perform tasks. The app silently takes more and more RAM it no longer needs, which forces the system that the software is running on to watch total available RAM in the system until a crisis occurs (e.g - the system runs out of memory).&lt;/p&gt;

&lt;p&gt;In short, resources are consumed until a system crash occurs.&lt;/p&gt;

&lt;p&gt;MCP Servers can have the same impact/outcome without proper rate limiting. LLMs retry if an error occurs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe075n0hgm1avuanlqv08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe075n0hgm1avuanlqv08.png" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is part of its programming to ensure it gets you at least some answer, even if the answer isn't correct. It wants to satisfy whoever is using it, so some answer is better than no answer. What this means, however, especially when making MCP tool calls, is that a non-rate-limiting loop can cause huge API bills or crash your system because the Agent hitting the LLM/MCP Server will eat up all available memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxwy2q9mizwdmhvp19uyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxwy2q9mizwdmhvp19uyj.png" alt=" " width="800" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With rate limiting for MCP, you can configure how many calls/requests can be made in a particular timeframe.&lt;/p&gt;

&lt;h2&gt;
  
  
  MCP Requests
&lt;/h2&gt;

&lt;p&gt;Before jumping into rate limiting MCP requests, it's important to understand what the workflow looks like.&lt;/p&gt;

&lt;p&gt;A typical MCP client HTTP tool call looks like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ Client ] -- HTTP POST /mcp (JSON-RPC: tools/call) --&amp;gt; [ Server ]
[ Client ] &amp;lt;-- HTTP 200 OK (JSON-RPC: result) --------- [ Server ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the client or Agent begins a request, it hits &lt;code&gt;tools/list&lt;/code&gt; one time to have an understanding of what MCP tools are available. The client/Agent then caches the tool schemas (name, description, input parameters) locally. That way, it's not always making a call to &lt;code&gt;tools-list&lt;/code&gt; as that would be incredibly inefficient and waste a ton of tokens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2700tk14roapg5986tpa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2700tk14roapg5986tpa.png" alt=" " width="800" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you tell an Agent to make a call, it looks at the local cache to see which tools fit. The tool can then be used by the Agent to perform an action (e.g - &lt;code&gt;search_repositories&lt;/code&gt; if you're using the GitHub Copilot MCP Server).&lt;/p&gt;

&lt;h3&gt;
  
  
  LLM vs MCP Rate Limiting
&lt;/h3&gt;

&lt;p&gt;When you limit LLM calls, you can specify the number of requests to an LLM based on a particular timeframe or limit tokens in a particular timeframe (e.g - 100 tokens every minute). MCP rate limiting is all about the number of requests to the MCP server in a specific timeframe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing MCP Rate Limiting
&lt;/h2&gt;

&lt;p&gt;With the theory of MCP rate limiting and MCP tool calls/requests discussed, let's get hands-on and learn how to implement rate limiting for MCP. This section will cover two configurations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configuring a Gateway to use an MCP server.&lt;/li&gt;
&lt;li&gt;The policy for rate limiting.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the example, you'll use the GitHub Copilot MCP Server purely because the majority of people have access to GitHub, so it makes the demonstration universal.&lt;/p&gt;

&lt;h3&gt;
  
  
  MCP Gateway Configuration
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a Kubernetes Secret that contains your GitHub PAT.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;export GITHUB_PAT=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&lt;/span&gt;

&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Secret&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-pat&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Opaque&lt;/span&gt;
&lt;span class="na"&gt;stringData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer ${GITHUB_PAT}"&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a Gateway object that uses &lt;code&gt;agentgateway&lt;/code&gt; as the Gateway Class.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-gateway&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;gatewayClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway&lt;/span&gt;
  &lt;span class="na"&gt;listeners&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp&lt;/span&gt;
      &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
      &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTP&lt;/span&gt;
      &lt;span class="na"&gt;allowedRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;namespaces&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Same&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create an agentgatewaybackend so the Gateway knows what to route to. In this case, it's the GitHub Copilot MCP Server.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayBackend&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;sessionRouting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Stateless&lt;/span&gt;
    &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-copilot&lt;/span&gt;
        &lt;span class="na"&gt;static&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;api.githubcopilot.com&lt;/span&gt;
          &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/mcp/&lt;/span&gt;
          &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StreamableHTTP&lt;/span&gt;
          &lt;span class="na"&gt;policies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;tls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="na"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;secretRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-pat&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a route/path with the reference as the agentgatewaybackend.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPRoute&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-route&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-gateway&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PathPrefix&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/mcp&lt;/span&gt;
      &lt;span class="na"&gt;backendRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
          &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
          &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayBackend&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Capture the Gateways IP in the &lt;code&gt;GATEWAY_IP&lt;/code&gt; environment variable.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GATEWAY_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get svc mcp-gateway -n agentgateway-system -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.status.loadBalancer.ingress[0].ip}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GATEWAY_IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Test the connection.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -v -sS -X POST &lt;span class="s2"&gt;"http://${GATEWAY_IP}:3000/mcp"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Accept: application/json, text/event-stream"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": { "name": "get_me", "arguments": {} }
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see an output similar to the below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7w5yenle6jzeqba5vske.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7w5yenle6jzeqba5vske.png" alt=" " width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  MCP Rate Limit Policy
&lt;/h3&gt;

&lt;p&gt;With the Gateway created, let's create and test a rate limit policy.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the below. Out of the box/by default, you'll see that all 11 requests to the MCP Server work just fine.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;1..11&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  curl -v -sS -o /dev/null -w &lt;span class="s2"&gt;"req $i: %{http_code}\n"&lt;/span&gt; \
    -X POST &lt;span class="s2"&gt;"http://${GATEWAY_IP}:3000/mcp"&lt;/span&gt; \
    -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
    -H &lt;span class="s2"&gt;"Accept: application/json, text/event-stream"&lt;/span&gt; \
    -d &lt;span class="s2"&gt;"{\"jsonrpc\":\"2.0\",\"id\":$i,\"method\":\"tools/list\"}"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fay8qh6vqrm7bmt7f0k48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fay8qh6vqrm7bmt7f0k48.png" alt=" " width="800" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a policy that blocks more than 10 requests
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f- &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayPolicy&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-rate-limit&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;targetRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPRoute&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-route&lt;/span&gt;
  &lt;span class="na"&gt;traffic&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;rateLimit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;local&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;burst&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
        &lt;span class="na"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Minutes&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Try running the &lt;code&gt;curl&lt;/code&gt; again without the &lt;code&gt;v&lt;/code&gt; flag for verbose.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;1..11&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  curl -sS -o /dev/null -w &lt;span class="s2"&gt;"req $i: %{http_code}\n"&lt;/span&gt; \
    -X POST &lt;span class="s2"&gt;"http://${GATEWAY_IP}:3000/mcp"&lt;/span&gt; \
    -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
    -H &lt;span class="s2"&gt;"Accept: application/json, text/event-stream"&lt;/span&gt; \
    -d &lt;span class="s2"&gt;"{\"jsonrpc\":\"2.0\",\"id\":$i,\"method\":\"tools/list\"}"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see that the 11th request failed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl4ph0utkk8b5rgg3dfa7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl4ph0utkk8b5rgg3dfa7.png" alt=" " width="594" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congrats! You've officially set up and configured rate limiting for an MCP Server.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mcp</category>
      <category>programming</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Stateless MCP With Compatible AI Gateways</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Mon, 10 Aug 2026 15:49:18 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/stateless-mcp-with-compatible-ai-gateways-4ne5</link>
      <guid>https://dev.to/thenjdevopsguy/stateless-mcp-with-compatible-ai-gateways-4ne5</guid>
      <description>&lt;p&gt;With the stateless MCP spec now officially out as of July 28th, 2026, there are now two methods of connecting to and configuring an MCP Server.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn what the stateless MCP spec means for the future, the breakdown of the spec, and how to implement it.&lt;/p&gt;

&lt;p&gt;💡I wrote a "engineering details quickstart" for some of the other changes that came with the new spec as well, which you can find here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stateless MCP Breakdown
&lt;/h2&gt;

&lt;p&gt;Two of the key changes in the &lt;code&gt;2026-07-28&lt;/code&gt; change: removal of initialization handshakes and session IDs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd6lo39fme979823j6sy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd6lo39fme979823j6sy2.png" alt=" " width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An initialization handshake was the startup exchange used by MCP versions through 2025-11-25.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client sends an initialize request containing its protocol version, capabilities, and client information.&lt;/li&gt;
&lt;li&gt;Server returns an InitializeResult with the negotiated version, server capabilities, and server information. It could also return MCP-Session-Id&lt;/li&gt;
&lt;li&gt;Client sends notifications/initialized.&lt;/li&gt;
&lt;li&gt;Normal MCP requests begin.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It established what features both sides supported before tools or resources were used.&lt;/p&gt;

&lt;p&gt;In MCP &lt;code&gt;2026-07-28&lt;/code&gt;, this handshake was removed. Each request instead carries its protocol version and client metadata, making requests independently processable and stateless.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnr6zxi148gibvfplxk9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnr6zxi148gibvfplxk9a.png" alt=" " width="799" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Session IDs were also removed, as anything with a session ID is stateful, since that ID serves as a lookup key for data stored on a server or in a database. Example: If you log into Gmail and look at the devices that are logged into Gmail (your phone, laptop, etc.), the reason you don't need to continuously log into them/daily login is that a session exists for that device.&lt;/p&gt;

&lt;h2&gt;
  
  
  Headers and Body
&lt;/h2&gt;

&lt;p&gt;Some headers must be in the body, and some headers that aren't. Standard HTTP headers (Content-Type, accept, Content-Length, etc.) don't need to be in the body. MCP headers that mirror requests, however, need to be in both the header and the body.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MCP-Protocol-Version&lt;/li&gt;
&lt;li&gt;Mcp-Method&lt;/li&gt;
&lt;li&gt;Mcp-Name&lt;/li&gt;
&lt;li&gt;Mcp-Param-*&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice how in the example below you'll see the name, method, and protocol version are in both. However, tool arguments aren't mirrored by default (e.g - &lt;code&gt;location&lt;/code&gt; is in the parameters, but not directly in the header).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="nc"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;
&lt;span class="no"&gt;MCP&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Protocol&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2026&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;07&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;
&lt;span class="nc"&gt;Mcp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;
&lt;span class="nc"&gt;Mcp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;get_weather&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"jsonrpc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tools/call"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"params"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"get_weather"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"arguments"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"location"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Seattle, WA"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"_meta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"io.modelcontextprotocol/protocolVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-07-28"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"io.modelcontextprotocol/clientInfo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"example-client"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"io.modelcontextprotocol/clientCapabilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building A Stateless MCP Server
&lt;/h2&gt;

&lt;p&gt;By default, popular methods for creating MCP Servers, like using the &lt;code&gt;fastmcp&lt;/code&gt; library, support stateless MCP out of the box (specifically using FastMCP 4 in this case).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastmcp&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;FastMCP&lt;/span&gt;

&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastMCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Weather"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_weather&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Weather for {location}"&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;http_app&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if you're using FastMCP 2 or 3, &lt;code&gt;stateless_http=True&lt;/code&gt; is what you would use to eliminate server-side Streamable HTTP sessions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;http_app&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stateless_http&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the above for stateless deployment of a legacy server, not as a substitute for FastMCP 4 when &lt;code&gt;2026-07-28&lt;/code&gt; compliance is required. Because of this, it's of course recommended to upgrade to FastMCP when able.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling Stateless MCP Servers
&lt;/h2&gt;

&lt;p&gt;There is a lot of talk around the idea that bringing the stateless MCP spec means you now have round-robin load balancing. Although this is true, it's important to understand that "technically", having a stateless app for load balancing in this fashion isn't "required", but it's certainly not ideal. It fails at three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Auth: A user or agent logs in and they're authenticated on that server with a session. However, if the next request goes to another server, they have to log in again.&lt;/li&gt;
&lt;li&gt;Data corruption: If an update occurs on the MCP Server, the update will only exist on the server that the update was implemented on.&lt;/li&gt;
&lt;li&gt;Dropped connections: Connections like WebSockets, which are long-lived, will disconnect and fail to reconnect properly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are ways to implement load balancing for stateful apps, though, like implementing state across a database/cache like Redis and enabling sticky sessions on a load balancer so it remembers to send the user to the same server where the user's request originated.&lt;/p&gt;

&lt;p&gt;Stateless workloads bring us far easier load balancing though. Taking the example from the previous paragraph, if the server goes down, regardless of whether sticky sessions are enabled or not, the server still isn't reachable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xv6x9fesgdwhgt2hc3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xv6x9fesgdwhgt2hc3o.png" alt=" " width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And truth be told, especially in the cloud-native community, we've all definitely gotten a bit used to the "ease of use" when it comes to statless (e.g - stateless microservices that run in Kubernetes that can easily be load balanced to with a k8s Service sitting in front).&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation With Agentgateway
&lt;/h2&gt;

&lt;p&gt;Before using the stateless MCP spec, ensure that the AI Gateway you're using supports it. Within agentgateway, it's been supported since day 0.&lt;/p&gt;

&lt;p&gt;To implement stateless MCP, you'll need three objects:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Gateway&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AgentgatewayBackend&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;HTTPRoute&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As an example, you can use the GitHub Copilot MCP Server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a k8s Secret with your GitHub Personal Access Token (PAT).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;export GITHUB_PAT=&lt;/span&gt;

&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Secret&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-pat&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Opaque&lt;/span&gt;
&lt;span class="na"&gt;stringData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer ${GITHUB_PAT}"&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a standard Gateway using the &lt;code&gt;agentgateway&lt;/code&gt; gateway class.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-gateway&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;gatewayClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway&lt;/span&gt;
  &lt;span class="na"&gt;listeners&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp&lt;/span&gt;
      &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
      &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTP&lt;/span&gt;
      &lt;span class="na"&gt;allowedRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;namespaces&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Same&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create an &lt;code&gt;AgentgatewayBackend&lt;/code&gt; with the &lt;code&gt;Stateless&lt;/code&gt; session routing option enabled (by default, it's &lt;code&gt;Stateful&lt;/code&gt;).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayBackend&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;sessionRouting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Stateless&lt;/span&gt;
    &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-copilot&lt;/span&gt;
        &lt;span class="na"&gt;static&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;api.githubcopilot.com&lt;/span&gt;
          &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/mcp/&lt;/span&gt;
          &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StreamableHTTP&lt;/span&gt;
          &lt;span class="na"&gt;policies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;tls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="na"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;secretRef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-pat&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a route so you can route traffic to your Stateless MCP connection via a client like MCP Inspector or an Agent.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl apply -f - &amp;lt;&amp;lt;EOF&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPRoute&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-route&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mcp-gateway&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PathPrefix&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/mcp&lt;/span&gt;
      &lt;span class="na"&gt;backendRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github-mcp-server&lt;/span&gt;
          &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway-system&lt;/span&gt;
          &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agentgateway.dev&lt;/span&gt;
          &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AgentgatewayBackend&lt;/span&gt;
&lt;span class="s"&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Retrieve your IP address.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GATEWAY_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get svc mcp-gateway -n agentgateway-system -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.status.loadBalancer.ingress[0].ip}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GATEWAY_IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test Connection
&lt;/h2&gt;

&lt;p&gt;Test your MCP Gateway connectivity by using a client like MCP Inspector, as it's a quick method of testing the connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx modelcontextprotocol/inspector#0.18.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use &lt;code&gt;http://YOUR_GATEWAY_IP:3000/mcp&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should now see the connection to the GitHub Copilot MCP Server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7n7vs1zf9js7lq9u4er5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7n7vs1zf9js7lq9u4er5.png" alt=" " width="800" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congrats! You've successfully learned what the stateless MCP protocol brings, how to implement the stateless MCP spec, and how to utilize it in an existing MCP server.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Enable MicroVM Agent Sandboxes with Agent Substrate (Kata + Cloud Hypervisor)</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Mon, 10 Aug 2026 15:47:13 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/enable-microvm-agent-sandboxes-with-agent-substrate-kata-cloud-hypervisor-k20</link>
      <guid>https://dev.to/thenjdevopsguy/enable-microvm-agent-sandboxes-with-agent-substrate-kata-cloud-hypervisor-k20</guid>
      <description>&lt;p&gt;Three times over the past month, the industry has seen Agents break out of sandboxes. It happened with OpenAI, Anthropic, and Meta Models. Despite them being "in a sandbox", there was still an entry point to the outside world.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;OpenAI used software isolation (network proxy + sandbox), not hardware isolation or true air-gapping. Anthropic and Meta didn't use hardware isolation either.&lt;/p&gt;

&lt;p&gt;This brings us to one question: is software isolation for sandboxing enough?&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn the key differences between software/hardware isolation, why hardware isolation will provide the best results for sandboxing, and how to implement it with MicroVM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post from a hands-on perspective, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GKE cluster&lt;/li&gt;
&lt;li&gt;Agent Substrate installed. You can learn how to do that here.&lt;/li&gt;
&lt;li&gt;A Node Pool that supports nested virtualization (e.g - &lt;code&gt;n2-standard-4&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The Substrate repo cloned. You can find it here.&lt;/li&gt;
&lt;li&gt;Snapshot bucket, which must allow the node/atelet identity to create objects (storage.objects.create, e.g. roles/storage.objectAdmin on the bucket). Read-only / bucketViewer is not enough for golden snapshots.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you don't have all of this right now, that's totally fine. It's still good to look through the blog so you get a conceptual understanding of how agent sandboxing will work with Agent Substrate using MicroVM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Substrate Installation Check
&lt;/h3&gt;

&lt;p&gt;To ensure Substrate is installed and working successfully, you can run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; .ate-dev-env.sh
kubectl get pods -n ate-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, ensure that there's a &lt;code&gt;sandboxClass&lt;/code&gt; on the nodes you're running to ensure the nodes can be enabled with MicroVM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get nodes -L ate.dev/sandboxClass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Catch-up on Agent Sandbox
&lt;/h2&gt;

&lt;p&gt;Sandboxes are isolation environments where Agents can run code, run tasks, edit files, and perform whatever actions are asked of it without harming your main server/system/laptop/desktop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F56xfq3ud0jk7efegujg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F56xfq3ud0jk7efegujg1.png" alt=" " width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, if you're running an Agent in a sandbox, it should ideally not be able to access the main file directory in your core system. That means it can't hit your home directory, documents folder, etc... On a production server, this is very important as it's serving a plethora of workloads that an organization is hosting.&lt;/p&gt;

&lt;h2&gt;
  
  
  MicroVM and gVisor
&lt;/h2&gt;

&lt;p&gt;gVisor isolation at the software/kernel level. It runs a separate app kernel in user space and intercepts system calls before they hit the host kernel. Its goal is to limit direct contact with the host kernel. When the app inside the sandbox triggers a system call, gVisor intercepts it.&lt;/p&gt;

&lt;p&gt;MicroVM provides isolation at the hardware level. It utilizes underlying virtualization technologies (e.g - VT-x, AMD-V) to spin up a tiny Linux kernel where the workloads run. It boots a stripped-down Linux kernel. This creates a true hardware-enforced boundary in comparison to gVisor creating a software sandbox boundary that still runs on the host kernel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frblhu1fj1n4ji3kdt9xc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frblhu1fj1n4ji3kdt9xc.png" alt=" " width="799" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Enabling MicroVM
&lt;/h2&gt;

&lt;p&gt;Now that you know a bit about hardware isolation, software isolation, and why agent sandboxing is drastically important for all agentic workloads, let's learn from a hands-on perspective how to enable hardware isolation in Agent Substrate with MicroVM.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the sandbox configuration. You'll see that by default, it;s gVisor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get sandboxconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To enable MicroVM for hardware isolation, you'll first need to get a list of your running nodes.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get nodes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Then, you can label one or all of the nodes to use MicroVM.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl label node &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;NODE_NAME&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ate.dev/sandboxClass=microvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that, your workloads are now ready to use hardware isolation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying Workloads That Use MicroVM
&lt;/h2&gt;

&lt;p&gt;To use hardware isolation, you'll of course need a workload that can utilize said isolation. Because there are going to be Actors that use MicroVM instead of gVisor, the first thing you may think is "do I need to specify the node to deploy to when creating an Actor?" and the answer is no. Actors are not scheduled onto nodes directly. Instead, the class is chosen via the template and matching pool.&lt;/p&gt;

&lt;p&gt;There are three objects you'll need to make this happen:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;SandboxConfig&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;WorkerPool&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ActorTemplate&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;SandboxConfig&lt;/code&gt; is, as the name suggests, the configuration for your MicroVM sandbox. A &lt;code&gt;WorkerPool&lt;/code&gt; is a set of pre-warmed sandbox Pods. When you see the term "Worker" used in Agent Substrate, it's the Pods where your Actors run. Actors can be anything from Agents to Web APIs. The &lt;code&gt;ActorTemplate&lt;/code&gt; is like the golden image for your Actors. It represents the saved state of an Actor, hence why there's a parameter for &lt;code&gt;snapshotsConfig&lt;/code&gt; where the state of your Actor is saved. You'll also see ateom used, which communicates directly with MicroVM (or gVisor) to manage the sandbox agent execution.&lt;/p&gt;

&lt;p&gt;Below is what an example config looks like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SandboxConfig&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-microvm&lt;/span&gt;   &lt;span class="c1"&gt;# any name
&lt;/span&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sandboxClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;microvm&lt;/span&gt;
  &lt;span class="c1"&gt;# default: true   # optional; at most one default per class
&lt;/span&gt;  &lt;span class="na"&gt;assets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;amd64&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="c1"&gt;# or arm64 — must match nodes
&lt;/span&gt;      &lt;span class="na"&gt;cloud-hypervisor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"gs://${BUCKET_NAME}/kata-assets/cloud-hypervisor"&lt;/span&gt;
        &lt;span class="na"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;sha&amp;gt;"&lt;/span&gt;
      &lt;span class="na"&gt;virtiofsd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"gs://${BUCKET_NAME}/kata-assets/virtiofsd"&lt;/span&gt;
        &lt;span class="na"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;sha&amp;gt;"&lt;/span&gt;
      &lt;span class="na"&gt;kata-kernel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"gs://${BUCKET_NAME}/kata-assets/vmlinux"&lt;/span&gt;
        &lt;span class="na"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;sha&amp;gt;"&lt;/span&gt;
      &lt;span class="na"&gt;kata-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"gs://${BUCKET_NAME}/kata-assets/rootfs.img"&lt;/span&gt;
        &lt;span class="na"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;sha&amp;gt;"&lt;/span&gt;
      &lt;span class="na"&gt;kata-config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"gs://${BUCKET_NAME}/kata-assets/configuration-clh.toml"&lt;/span&gt;
        &lt;span class="na"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;sha&amp;gt;"&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;WorkerPool&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-microvm-pool&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-ns&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;workload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-microvm&lt;/span&gt;   &lt;span class="c1"&gt;# optional; for workerSelector
&lt;/span&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
  &lt;span class="na"&gt;sandboxClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;microvm&lt;/span&gt;
  &lt;span class="na"&gt;sandboxConfigName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-microvm&lt;/span&gt;          &lt;span class="c1"&gt;# points at #1
&lt;/span&gt;  &lt;span class="na"&gt;ateomImage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ko://github.com/agent-substrate/substrate/cmd/ateom-microvm&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ate.dev/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ActorTemplate&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-ns&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sandboxClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;microvm&lt;/span&gt;                  &lt;span class="c1"&gt;# must match pool
&lt;/span&gt;  &lt;span class="na"&gt;pauseImage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"registry.k8s.io/pause:3.10.2@sha256:..."&lt;/span&gt;  &lt;span class="c1"&gt;# as in demos
&lt;/span&gt;  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;your-workload-image&amp;gt;&lt;/span&gt;
    &lt;span class="na"&gt;readyz&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/readyz&lt;/span&gt;   &lt;span class="c1"&gt;# whatever your app exposes
&lt;/span&gt;        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
  &lt;span class="na"&gt;workerSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                        &lt;span class="c1"&gt;# optional but usual
&lt;/span&gt;    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;workload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-microvm&lt;/span&gt;
  &lt;span class="na"&gt;snapshotsConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gs://${BUCKET_NAME}/my-app/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'd then use the following to deploy an Actor via the Template that you created within an atespace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate create atespace demo   &lt;span class="c"&gt;# if needed&lt;/span&gt;
kubectl ate create actor my-actor-1 -a demo --template my-ns/my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  MicroVM Demo
&lt;/h2&gt;

&lt;p&gt;Instead of creating your own, you can use the upstream MicroVM demo that's within the Agent Substrate repo.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Verify the asset and deploy. The below does the following:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;code&gt;assemble.sh&lt;/code&gt;&lt;/em&gt;:&lt;/strong&gt; Download/build the microVM runtime binaries for &lt;code&gt;amd64&lt;/code&gt; into &lt;code&gt;bin/microvm-assets/amd64/&lt;/code&gt; (&lt;code&gt;cloud-hypervisor&lt;/code&gt;, &lt;code&gt;virtiofsd&lt;/code&gt;, guest kernel, rootfs, config). Local only; nothing is applied to the cluster yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;code&gt;stage-to-gcs.sh&lt;/code&gt;&lt;/em&gt;:&lt;/strong&gt; Upload those binaries to &lt;code&gt;gs://$BUCKET_NAME/kata-assets/&lt;/code&gt; so atelet can fetch them when workers start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;code&gt;VIRTIOFSD_SHA256=...&lt;/code&gt;&lt;/em&gt;:&lt;/strong&gt; Compute the sha256 of the staged &lt;code&gt;virtiofsd&lt;/code&gt;binary so the SandboxConfig pin matches what was uploaded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;code&gt;sed ... counter-microvm.yaml.tmpl&lt;/code&gt;&lt;/em&gt;:&lt;/strong&gt; Substitute &lt;code&gt;$BUCKET_NAME&lt;/code&gt; and the virtiofsd hash into the demo template (namespace, SandboxConfig, WorkerPool, ActorTemplate).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;code&gt;ko apply&lt;/code&gt;&lt;/em&gt;:&lt;/strong&gt; Build/push any &lt;code&gt;ko://&lt;/code&gt; images in that manifest (e.g. &lt;code&gt;ateom-microvm&lt;/code&gt;, counter workload) to your registry and apply the rendered YAML to the cluster. The images need to be built/pushed for the microvm demo so the Actor can access them.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; .ate-dev-env.sh

&lt;span class="nv"&gt;OUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$PWD/bin/microvm-assets/amd64"&lt;/span&gt;

&lt;span class="nv"&gt;VIRTIOFSD_SHA256&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(sha256sum "&lt;/span&gt;&lt;span class="nv"&gt;${OUT}&lt;/span&gt;/virtiofsd&lt;span class="s2"&gt;" | awk '{print $1}')"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"sha=$VIRTIOFSD_SHA256"&lt;/span&gt;

sed -e &lt;span class="s2"&gt;"s|\${BUCKET_NAME}|${BUCKET_NAME}|g"&lt;/span&gt; \
    -e &lt;span class="s2"&gt;"s|\${VIRTIOFSD_SHA256}|${VIRTIOFSD_SHA256}|g"&lt;/span&gt; \
    demos/counter/counter-microvm.yaml.tmpl \
  &lt;span class="o"&gt;|&lt;/span&gt; ./hack/run-tool.sh ko apply -f - -- --context=&lt;span class="s2"&gt;"${KUBECTL_CONTEXT}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Wait for the workload to be ready.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;wait&lt;/span&gt; --for=condition=Ready \
  actortemplate/counter-microvm -n ate-demo-counter-microvm --timeout=600s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create the atespace and deploy the Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate create atespace demo

kubectl ate create actor my-counter-1 -a demo \
  --template ate-demo-counter-microvm/counter-microvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Port-forward the atenet-router so you can reach the Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl -n ate-system port-forward svc/atenet-router 8000:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Hit the Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -X POST \
  -H &lt;span class="s2"&gt;"Host: my-counter-1.demo.actors.resources.substrate.ate.dev"&lt;/span&gt; \
  http://localhost:8000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the one below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hello from: 169.254.17.2 | preserved memory count: 1 | preserved file counter: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congrats! You have successfully deployed an Actor that uses hardware isolation utilizing MicroVM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;The AI world is fast-moving, as many of us can attest to. As a technology moves quickly and changes all of the time, it's incredibly difficult to secure it because there aren't specific standards to go off of to secure the workloads. As we've seen with the major AI providers over the past month, without proper security and isolation, Agents will never be able to truly be trusted within sandboxed environments. That's why hardware isolation is crucial to ensuring Agent success.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Live Actor Migration in Agent Substrate: Moving State Across Workers</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sat, 11 Jul 2026 16:17:56 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/live-actor-migration-in-agent-substrate-moving-state-across-workers-146m</link>
      <guid>https://dev.to/thenjdevopsguy/live-actor-migration-in-agent-substrate-moving-state-across-workers-146m</guid>
      <description>&lt;p&gt;High Availability (HA) is the cornerstone of an efficient, scalable, performant system. Without it, zero downtime and migrating/scaling state for systems would be impossible. In this case, the "system" is Agents, and the ability to accomplish this is with sandboxing.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn how to accomplish this for your Agents with Agent Substrate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this blog post from a hands-on perspective, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GKE or kind cluster.&lt;/li&gt;
&lt;li&gt;Substrate installed (you can learn how to do that here).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you don't have a cluster running, you can still follow along from a theoretical perspective and implement once a cluster is at your fingertips.&lt;/p&gt;

&lt;h2&gt;
  
  
  How The Actor Teleports
&lt;/h2&gt;

&lt;p&gt;In Agent Substrate, you'll notice that unless an Actor is being used, it's in a &lt;code&gt;SUSPENDED&lt;/code&gt; state. This is a mechanism built into Substrate on purpose to enable efficiency for Agents. The goal is for Agents to be "on" only when necessary.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhskbgor10cehex8843uh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhskbgor10cehex8843uh.png" alt=" " width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Having the ability to restore the Agent, aside from the fact that you can then use it, allows you to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cut costs by up to 90%.&lt;/li&gt;
&lt;li&gt;Cut startup times. Cold booting a new Agent could take minutes; resuming an existing Agent takes seconds.&lt;/li&gt;
&lt;li&gt;State persistence (the point of this blog) - when an Agent restores, it remembers what's in its context (e.g - chat history).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Two Actors, One ID
&lt;/h2&gt;

&lt;p&gt;When creating Actors, you can give them the same ID if they are created as different Actor types or within different Actor Spaces (like Namespaces, but for Actors). The host is identified as &lt;code&gt;actorID.actorNamespace&lt;/code&gt; along with the standard &lt;code&gt;resources.substrate.ate.dev&lt;/code&gt; path.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5ze4tm6zkilqpo1hduk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5ze4tm6zkilqpo1hduk.png" alt=" " width="799" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create two actorspaces.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;kubectl ate create atespace tenant-a
kubectl ate create atespace tenant-b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create two actors, each with the same ID and using the same template, and place them in their respective actorspaces.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;kubectl ate create actor agent-1 --template=ate-demo-counter/counter --atespace=tenant-a
kubectl ate create actor agent-1 --template=ate-demo-counter/counter --atespace=tenant-b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Ensure that both Actors are deployed.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;kubectl ate get actors -A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;With both Actors deployed, drive traffic to them to ensure they're operational.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl -n ate-system port-forward svc/atenet-router 8000:80 &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;

&lt;span class="c"&gt;# Hit tenant-a's agent-1 three times&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; 1 2 3&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  curl -s -H &lt;span class="s2"&gt;"Host: agent-1.tenant-a.actors.resources.substrate.ate.dev"&lt;/span&gt; http://localhost:8000/
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# Hit tenant-b's agent-1 once&lt;/span&gt;
curl -s -H &lt;span class="s2"&gt;"Host: agent-1.tenant-b.actors.resources.substrate.ate.dev"&lt;/span&gt; http://localhost:8000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hello from: &amp;lt;sandbox-ip&amp;gt; | preserved memory count: 3 | preserved file counter: 3
hello from: &amp;lt;sandbox-ip&amp;gt; | preserved memory count: 1 | preserved file counter: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This proves out the tenancy piece. You gave the Actors the same name (which means the same Actor ID), the same template, and same&lt;code&gt;WorkerPool&lt;/code&gt;, but tenant-a's count is 3 and tenant-b's is 1. Neither tenant can address or observe the other's actions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Suspend and Move Actor
&lt;/h2&gt;

&lt;p&gt;In this section, you will do two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Suspend the actor&lt;/strong&gt;: the two tenants each run an actor with the same ID (&lt;code&gt;agent-1&lt;/code&gt;), and Substrate keeps its state, addressing, and snapshots completely separate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State teleport&lt;/strong&gt;: once the Actor is suspended (checkpointed to object storage, Worker released) and resumed onto a different Worker, its state continues exactly where it left off.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This proves that the Pod is cattle and the actor's state is the stable thing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F64xwkec7si06jc2mugg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F64xwkec7si06jc2mugg1.png" alt=" " width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the Actors current state so you can prove that the IP changes when you move the Actor. With the command below, you'll get the IP.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate get actors --atespace=tenant-a
curl -s -H &lt;span class="s2"&gt;"Host: agent-1.tenant-a.actors.resources.substrate.ate.dev"&lt;/span&gt; http://localhost:8000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Suspend the Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor agent-1 --atespace=tenant-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The counter demo's &lt;code&gt;WorkerPoo&lt;/code&gt;l has 5 replicas; parking a few filler actors in the pool takes the old slot. Use 3 fillers, not more. Tenant-b's&lt;code&gt;agent-1&lt;/code&gt;may still be running (idle-suspend takes about a minute), and 3 fillers + tenant-b. The slot you're saving for the wake-up accounts for all 5 workers. The placement picks any free worker, which makes a different worker likely, but not guaranteed. If the Agent lands on the same Worker, suspend it and repeat with another filler.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; 1 2 3&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate create actor filler-&lt;span class="nv"&gt;$i&lt;/span&gt; --template=ate-demo-counter/counter --atespace=tenant-b
  curl -s -H &lt;span class="s2"&gt;"Host: filler-$i.tenant-b.actors.resources.substrate.ate.dev"&lt;/span&gt; http://localhost:8000/ &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡&lt;/p&gt;

&lt;p&gt;Substrate has no explicit "migrate actor" API. An actor's snapshot lives in object storage, and its next resume simply restores it onto whichever free worker the placement logic picks (a random shuffle over free Workers with no affinity to or away from the previous pod). The demo wants to prove a cross-worker resume; that session identity travels with the actor rather than being tied to the Worker. However, after suspension, the Actors old Worker returns to the free pool, so a random pick could land it right back on the same pod and demonstrate nothing. The filler step rigs the odds: each &lt;code&gt;kubectl ate create actor&lt;/code&gt; filler deliberately creates a brand-new actor (not a move of the suspended one), and the &lt;code&gt;curl&lt;/code&gt; triggers its first resume purely to claim a Worker slot, occupying the old worker so the target Actors wake-up probably lands elsewhere.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Wake the Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -H &lt;span class="s2"&gt;"Host: agent-1.tenant-a.actors.resources.substrate.ate.dev"&lt;/span&gt; http://localhost:8000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Get the output from the Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;kubectl ate get actors --atespace=tenant-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see that the Actor is fully restored on another Worker with the same state.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cleanup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; 1 2 3&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor filler-&lt;span class="nv"&gt;$i&lt;/span&gt; --atespace=tenant-b 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
  kubectl ate delete actor filler-&lt;span class="nv"&gt;$i&lt;/span&gt; --atespace=tenant-b
&lt;span class="k"&gt;done&lt;/span&gt;
kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor agent-1 --atespace=tenant-a 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
kubectl ate delete actor agent-1 --atespace=tenant-a
kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor agent-1 --atespace=tenant-b 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
kubectl ate delete actor agent-1 --atespace=tenant-b
kubectl ate delete atespace tenant-a
kubectl ate delete atespace tenant-b
&lt;span class="c"&gt;# Leave the system-managed `ate-golden` atespace alone - the control plane&lt;/span&gt;
&lt;span class="c"&gt;# uses it for golden-snapshot actors.&lt;/span&gt;

&lt;span class="c"&gt;# Stop the router port-forward&lt;/span&gt;
&lt;span class="nb"&gt;kill&lt;/span&gt; %1 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Pods fail for multiple reasons, and they also move from one Worker Node to another. To ensure that Actors keep state intact (e.g - the Agent they're running), there needs to be the ability to move them from one Worker to another without losing data. In this blog post, you learned how to ensure Actors can move between Workers while still keeping state and Actor Identity.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>kubernetes</category>
      <category>googlecloud</category>
    </item>
    <item>
      <title>Cutting Idle Agent Costs by 90% with Agent Substrate</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Tue, 30 Jun 2026 12:40:06 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/cutting-idle-agent-costs-by-90-with-agent-substrate-18en</link>
      <guid>https://dev.to/thenjdevopsguy/cutting-idle-agent-costs-by-90-with-agent-substrate-18en</guid>
      <description>&lt;p&gt;Cost is everything. In just about every agentic conversation, the three things that come up for enterprises implementing AI workloads are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cost&lt;/li&gt;
&lt;li&gt;Observability&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;and as AI continues to throw everyone for a loop when it comes to cost management (e.g - Uber running out of the yearly token budget in one quarter), the ability to shrink resource (like hardware) usage will be crucial moving forward.&lt;/p&gt;

&lt;p&gt;In this blog post, you will learn how to cust costs by 90% using Agent Susbtrate in comparison to Agents running in k8s Deployments/Pods.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Cost Comparison
&lt;/h2&gt;

&lt;p&gt;Agents need a place to run. The "place to run" needs to be a platform that's easily managed, orchestrated, and has the ability to cluster resources. Resources like CPU, GPU, and memory need to be able to scale and expand. Without this, it's a matter of manually managing servers that Agents are running on and clients to interact with said server.&lt;/p&gt;

&lt;p&gt;That's why so many organizations choose Kubernetes to run Agentic.&lt;/p&gt;

&lt;p&gt;When running Agents per Pod, however, that can get costly very quick in terms of hardware (GPU, CPU, memory) and performance (can your cluster scale up and down quickly based on resource needs when it comes to Agents coming up and going down per use?).&lt;/p&gt;

&lt;p&gt;The tests in this blog post show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always-on Agents running in k8s.&lt;/li&gt;
&lt;li&gt;Actors running in Workers via Agent Substrate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the comparison will be 50 always-on Pods in comparison to 50 Actors across 5-7 Workers (Pods). If there are 50 Agents running per Pod and 50 Agents running per Worker with 5-10 Actors per Pod, you can already imagine the hardware resource savings that can be accomplished.&lt;/p&gt;

&lt;p&gt;Right now, the majority of organizations start off with the "one Agent per Pod" approach as that's the fastest way to show value and get up and running. For the future, however, Agents in Actors via Agent Substrate will be how organizations deploy when they care about efficiency, optimization, and managing cost.&lt;/p&gt;

&lt;p&gt;Let's dive in from a hands-on perspective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along in a hands-on fashion, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Kubernetes cluster in GKE or Kind locally&lt;/li&gt;
&lt;li&gt;Agent Substrate installed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl-ate&lt;/code&gt; installed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can install Agent Substrate and &lt;code&gt;kubectl-ate&lt;/code&gt; from the Agent Substrate repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation &amp;amp; Configuration
&lt;/h2&gt;

&lt;p&gt;Within the Agent Substrate repo, you will see a file in the &lt;code&gt;hack&lt;/code&gt; directory called &lt;code&gt;ate-dev-env.sh.example&lt;/code&gt;. Make a copy of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp hack/ate-dev-env.sh.example .ate-dev-env.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, edit the file with your cluster and account information. For example, if you are using GCP and deploy a GKE cluster, the &lt;code&gt;.ate-dev-env.sh&lt;/code&gt; will look like the below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;your-project-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;PROJECT_NUMBER&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;your-project-number&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;GCE_REGION&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;bucket-region&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;CLUSTER_LOCATION&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;cluster-zone-or-region&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;CLUSTER_NAME&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;your-gke-cluster&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;BUCKET_NAME&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;your-snapshot-bucket&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;KO_DOCKER_REPO&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gcr.io/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-project-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/ate-images
&lt;span class="nv"&gt;KUBECTL_CONTEXT&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;your-kube-context&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you've filled in your &lt;code&gt;.ate-dev-env.sh&lt;/code&gt; file, you can source it and install the counter demo which exists in the Agent Substrate repo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; .ate-dev-env.sh
./hack/install-ate.sh --deploy-demo-counter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then install the &lt;code&gt;kubectl-ate&lt;/code&gt; CLI to interact with Actors, Workers, and Templates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go install ./cmd/kubectl-ate

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(go env GOPATH)/bin:$PATH"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that Substrate is up and operational:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get workerpools.ate.dev counter -n ate-demo-counter
kubectl get pods -n ate-demo-counter
kubectl ate get workers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A Quick Note About GKE
&lt;/h3&gt;

&lt;p&gt;If your GKE cluster is regional or has Worker Nodes spread across zones, pin the demo &lt;code&gt;WorkerPool&lt;/code&gt; to one zone before creating benchmark actors. Agent Substrate uses &lt;code&gt;checkpoint/restore&lt;/code&gt;, and gVisor restores can fail if a snapshot created on oneunderlying CPU platform is restored on a node with a different CPU feature set.&lt;/p&gt;

&lt;p&gt;Choose the zone where you want the counter workers to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_WORKER_ZONE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;us-east1-d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then patch the counter &lt;code&gt;WorkerPool&lt;/code&gt; to schedule Workers in that zone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl patch workerpools.ate.dev counter \
  -n ate-demo-counter \
  --type=merge \
  -p &lt;span class="s2"&gt;"{\"spec\":{\"template\":{\"nodeSelector\":{\"topology.kubernetes.io/zone\":\"${SUBSTRATE_WORKER_ZONE}\"}}}}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configure The Benchmark
&lt;/h2&gt;

&lt;p&gt;With the installation and configuration complete, you can now start setting up the benchmark environment and tests.&lt;/p&gt;

&lt;p&gt;There are several environment variables below. The &lt;code&gt;ACTOR_COUNT&lt;/code&gt; is the number of logical counter agents to test in both scenarios. &lt;code&gt;BENCHMARK_NAMESPACE&lt;/code&gt; | is the namespace for the always-on Kubernetes baseline workloads and the in-cluster benchmark client Pod. &lt;code&gt;BASELINE_PREFIX&lt;/code&gt; is the name prefix for Kubernetes baseline Deployments and Services. &lt;code&gt;SUBSTRATE_PREFIX&lt;/code&gt; is the name prefix for Substrate actors created by the benchmark. &lt;code&gt;TEMPLATE_REF&lt;/code&gt; is the Substrate actor template reference in &lt;code&gt;&amp;lt;namespace&amp;gt;/&amp;lt;name&amp;gt;&lt;/code&gt; format. The counter demo creates &lt;code&gt;ate-demo-counter/counter&lt;/code&gt;. &lt;code&gt;SUBSTRATE_ROUTER_URL&lt;/code&gt; is the in-cluster URL for &lt;code&gt;atenet-router&lt;/code&gt;; benchmark client sends Substrate actor traffic through this service. &lt;code&gt;BASELINE_CPU_REQUEST&lt;/code&gt; is the requests assigned to each always-on Kubernetes baseline Pod. Used to make baseline resource consumption explicit. &lt;code&gt;BASELINE_MEMORY_REQUEST&lt;/code&gt; is the memory request assigned to each always-on Kubernetes baseline Pod and is used to make baseline resource consumption explicit. &lt;code&gt;BASELINE_RESULTS_FILE&lt;/code&gt; is the Local TSV file for Kubernetes baseline latency results. &lt;code&gt;SUBSTRATE_RESULTS_FILE&lt;/code&gt;  and &lt;code&gt;SUMMARY_FILE&lt;/code&gt; are the files that contain the results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ACTOR_COUNT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;BENCHMARK_NAMESPACE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cost-comparison
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;BASELINE_PREFIX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;k8s-counter
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_PREFIX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;substrate-counter
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;TEMPLATE_REF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ate-demo-counter/counter
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_ROUTER_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://atenet-router.ate-system.svc:80

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;BASELINE_CPU_REQUEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50m
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;BASELINE_MEMORY_REQUEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;64Mi
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_WORKER_CPU_REQUEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50m
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_WORKER_MEMORY_REQUEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;64Mi

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;BASELINE_RESULTS_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;baseline-kubernetes-results.tsv
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_RESULTS_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;substrate-results.tsv
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUMMARY_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cost-comparison-summary.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Get the counter image from the live &lt;code&gt;ActorTemplate&lt;/code&gt;. This keeps the Kubernetes baseline on the same counter server image used by the Substrate demo.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;COUNTER_IMAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get actortemplates.ate.dev counter \
  -n ate-demo-counter \
  -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.spec.containers[0].image}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"Counter image: %s\n"&lt;/span&gt; &lt;span class="s2"&gt;"$COUNTER_IMAGE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Check the image. If the output from the following is blank, that means the container image is valid.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"$COUNTER_IMAGE"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
  ko://*&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"Counter image was not resolved: %s\n"&lt;/span&gt; &lt;span class="s2"&gt;"$COUNTER_IMAGE"&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 1
    &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Retrieve the Substrate Worker count.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;WORKER_REPLICAS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get workerpools.ate.dev counter \
  -n ate-demo-counter \
  -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.spec.replicas}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"Logical agents: %s\nSubstrate workers: %s\n"&lt;/span&gt; \
  &lt;span class="s2"&gt;"$ACTOR_COUNT"&lt;/span&gt; &lt;span class="s2"&gt;"$WORKER_REPLICAS"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Deploying Kubernetes Always-On Pods
&lt;/h2&gt;

&lt;p&gt;In this section, you will deploy the Kubernetes Pods that will be running the counter demo.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a Namespace for the Pods to exist.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create namespace &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Deploy one &lt;code&gt;Deployment&lt;/code&gt; and &lt;code&gt;Service&lt;/code&gt; object per logical counter Agent.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 &lt;span class="s2"&gt;"$ACTOR_COUNT"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s-%03d"&lt;/span&gt; &lt;span class="s2"&gt;"$BASELINE_PREFIX"&lt;/span&gt; &lt;span class="s2"&gt;"$i"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

  kubectl apply -f - &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: &lt;span class="nv"&gt;${name}&lt;/span&gt;
  namespace: &lt;span class="nv"&gt;${BENCHMARK_NAMESPACE}&lt;/span&gt;
  labels:
    app.kubernetes.io/name: counter
    app.kubernetes.io/part-of: cost-comparison
    cost-comparison/model: always-on-kubernetes
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: counter
      app.kubernetes.io/instance: &lt;span class="nv"&gt;${name}&lt;/span&gt;
  template:
    metadata:
      labels:
        app.kubernetes.io/name: counter
        app.kubernetes.io/instance: &lt;span class="nv"&gt;${name}&lt;/span&gt;
        app.kubernetes.io/part-of: cost-comparison
        cost-comparison/model: always-on-kubernetes
    spec:
      containers:
      - name: counter
        image: &lt;span class="nv"&gt;${COUNTER_IMAGE}&lt;/span&gt;
        command:
        - /ko-app/counter
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: &lt;span class="nv"&gt;${BASELINE_CPU_REQUEST}&lt;/span&gt;
            memory: &lt;span class="nv"&gt;${BASELINE_MEMORY_REQUEST}&lt;/span&gt;
---
apiVersion: v1
kind: Service
metadata:
  name: &lt;span class="nv"&gt;${name}&lt;/span&gt;
  namespace: &lt;span class="nv"&gt;${BENCHMARK_NAMESPACE}&lt;/span&gt;
  labels:
    app.kubernetes.io/name: counter
    app.kubernetes.io/part-of: cost-comparison
    cost-comparison/model: always-on-kubernetes
spec:
  selector:
    app.kubernetes.io/name: counter
    app.kubernetes.io/instance: &lt;span class="nv"&gt;${name}&lt;/span&gt;
  ports:
  - name: http
    port: 80
    targetPort: 80
EOF
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Confirm the baseline.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get deployments -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  -l cost-comparison/model=always-on-kubernetes

kubectl get pods -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  -l cost-comparison/model=always-on-kubernetes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output with 50 objects like in the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME                               READY   STATUS    RESTARTS   AGE
k8s-counter-001-9f9f44464-h526d    1/1     Running   0          128m
k8s-counter-002-9678fb86f-bwpwm    1/1     Running   0          128m
k8s-counter-003-54bccfd7db-k5wgz   1/1     Running   0          128m
k8s-counter-004-5957785959-59k24   1/1     Running   0          128m
k8s-counter-005-5df4559dd4-pgm4v   1/1     Running   0          128m
k8s-counter-006-5597c6cd9-nj9mm    1/1     Running   0          128m
k8s-counter-007-8d5c5bb74-j2n6p    1/1     Running   0          128m
k8s-counter-008-ff9898c5f-hc7hw    1/1     Running   0          128m
k8s-counter-009-77bc4cf8bd-rk2sq   1/1     Running   0          128m
k8s-counter-010-578684f8c8-d7xg8   1/1     Running   0          128m
k8s-counter-011-8697447c4f-5jz9p   1/1     Running   0          128m
k8s-counter-012-5d7bc67f4d-hhhkh   1/1     Running   0          128m
xxxxx
xxxxx
xxxxx
xxxxx
xxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create Substrate Actors
&lt;/h2&gt;

&lt;p&gt;In this configuration, you can create one Actor per logical counter Agent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 &lt;span class="s2"&gt;"$ACTOR_COUNT"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s-%03d"&lt;/span&gt; &lt;span class="s2"&gt;"$SUBSTRATE_PREFIX"&lt;/span&gt; &lt;span class="s2"&gt;"$i"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  kubectl ate create actor &lt;span class="s2"&gt;"$actor"&lt;/span&gt; --template &lt;span class="s2"&gt;"$TEMPLATE_REF"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run the above, you will see 50 Actors deployed via &lt;code&gt;kubectl ate get actors&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff6nni2xcnacq3pfi50tb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff6nni2xcnacq3pfi50tb.png" alt=" " width="798" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, you will only see 7 Workers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzap3gyme2bkpbtp4guuw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzap3gyme2bkpbtp4guuw.png" alt=" " width="798" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's the optimization and efficiency right there. Same exact deployment/configuration as the Kubernetes section above, except with Agent Substrate, you can run the same workloads in 7 Pods (Workers) insteadof 50.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Actors Work
&lt;/h3&gt;

&lt;p&gt;You’ll see 50 Agent Substrate Actors and a smaller set of Workers (Pods). The Actors are logical workloads, but they are not actively running while they are &lt;code&gt;STATUS_SUSPENDED&lt;/code&gt;. By default, Actors are in a "suspended" state until they are used, which is why Actors are so great from an efficiency perspective. When traffic arrives for an Actor, Agent Substrate assigns that actor to an available Worker, resumes it, serves the request, and can suspend it again afterward. This is the efficiency model: many idle actors can exist without each requiring its own always-on Kubernetes Pod.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Benchmark Client
&lt;/h2&gt;

&lt;p&gt;The benchmark client runs inside the cluster so both paths avoid local port-forward overhead.&lt;/p&gt;

&lt;p&gt;benchmark-client = temporary in-cluster curl Pod.&lt;/p&gt;

&lt;p&gt;Why it exists:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sends requests to the Kubernetes baseline Services.&lt;/li&gt;
&lt;li&gt;Sends requests to Substrate through atenet-router.- Avoids local kubectl port-forward latency.&lt;/li&gt;
&lt;li&gt;Keeps both benchmark paths inside the cluster network for a fairer comparison.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete pod benchmark-client \
  -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  --ignore-not-found

kubectl run benchmark-client \
  -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  --image=curlimages/curl:8.10.1 \
  --restart=Never \
  --command -- sleep 3600

kubectl &lt;span class="nb"&gt;wait&lt;/span&gt; --for=condition=Ready pod/benchmark-client \
  -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  --timeout=2m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Run The Benchmark For Kubernetes Always On
&lt;/h2&gt;

&lt;p&gt;Each baseline agent receives two requests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First measured request.&lt;/li&gt;
&lt;li&gt;Second warm request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because these are always-on Pods, both requests should be served by already running Kubernetes workloads.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; benchmark-client -- sh -c &lt;span class="s1"&gt;'
set -eu
actor_count="$1"
prefix="$2"
namespace="$3"

printf "agent\tfirst_seconds\twarm_seconds\n"

for i in $(seq 1 "$actor_count"); do
  name=$(printf "%s-%03d" "$prefix" "$i")
  url="http://${name}.${namespace}.svc.cluster.local"

  first_seconds=$(curl -sS -o /dev/null -w "%{time_total}" -X POST "$url")
  warm_seconds=$(curl -sS -o /dev/null -w "%{time_total}" -X POST "$url")

  printf "%s\t%s\t%s\n" "$name" "$first_seconds" "$warm_seconds"
done
'&lt;/span&gt; sh &lt;span class="s2"&gt;"$ACTOR_COUNT"&lt;/span&gt; &lt;span class="s2"&gt;"$BASELINE_PREFIX"&lt;/span&gt; &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"$BASELINE_RESULTS_FILE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the baseline results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;column -t -s &lt;span class="s1"&gt;$'\t'&lt;/span&gt; &lt;span class="s2"&gt;"$BASELINE_RESULTS_FILE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see an output similar to the below for 50 counters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;agent            first_seconds  warm_seconds
k8s-counter-001  0.023404       0.003911
k8s-counter-002  0.023275       0.005233
k8s-counter-003  0.015850       0.003773
k8s-counter-004  0.017657       0.005033
k8s-counter-005  0.014946       0.004443
k8s-counter-006  0.015616       0.004212
k8s-counter-007  0.016875       0.004261
k8s-counter-008  0.014731       0.004317
k8s-counter-009  0.017053       0.004707
k8s-counter-010  0.013013       0.003273
k8s-counter-011  0.014281       0.004552
k8s-counter-012  0.018644       0.003734
xxxxx
xxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Run The Benchmark For Substrate
&lt;/h2&gt;

&lt;p&gt;Each Substrate actor receives two requests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wake request, which resumes a suspended Actor and serves the request.&lt;/li&gt;
&lt;li&gt;Warm request, which hits the already-running Actor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After each actor is measured, the Actor is suspended so the worker can serve the next Actor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"actor\twake_seconds\twarm_seconds\n"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"$SUBSTRATE_RESULTS_FILE"&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;seq 1 &lt;span class="s2"&gt;"$ACTOR_COUNT"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s-%03d"&lt;/span&gt; &lt;span class="s2"&gt;"$SUBSTRATE_PREFIX"&lt;/span&gt; &lt;span class="s2"&gt;"$i"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nv"&gt;actor_host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${actor}.actors.resources.substrate.ate.dev"&lt;/span&gt;

  &lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; benchmark-client -- sh -c &lt;span class="s1"&gt;'
set -eu
router_url="$1"
actor_host="$2"

wake_seconds=$(curl -sS -o /dev/null -w "%{time_total}" \
  -X POST \
  -H "Host: ${actor_host}" \
  "$router_url")

warm_seconds=$(curl -sS -o /dev/null -w "%{time_total}" \
  -X POST \
  -H "Host: ${actor_host}" \
  "$router_url")

printf "%s\t%s" "$wake_seconds" "$warm_seconds"
'&lt;/span&gt; sh &lt;span class="s2"&gt;"$SUBSTRATE_ROUTER_URL"&lt;/span&gt; &lt;span class="s2"&gt;"$actor_host"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

  &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s\t%s\n"&lt;/span&gt; &lt;span class="s2"&gt;"$actor"&lt;/span&gt; &lt;span class="s2"&gt;"$result"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"$SUBSTRATE_RESULTS_FILE"&lt;/span&gt;
  kubectl ate &lt;span class="nb"&gt;suspend&lt;/span&gt; actor &lt;span class="s2"&gt;"$actor"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inspect the Substrate results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;column -t -s &lt;span class="s1"&gt;$'\t'&lt;/span&gt; &lt;span class="s2"&gt;"$SUBSTRATE_RESULTS_FILE"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Results
&lt;/h2&gt;

&lt;p&gt;Now it's time to measure the results and see if Substrate really saves resources and helps optimize workloads running in k8s.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;BASELINE_RUNNING_PODS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get pods \
  -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  -l cost-comparison/model=always-on-kubernetes \
  --field-selector=status.phase=Running \
  --no-headers &lt;span class="o"&gt;|&lt;/span&gt; wc -l &lt;span class="o"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUBSTRATE_WORKLOAD_PODS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;kubectl get pods \
  -n ate-demo-counter \
  --field-selector=status.phase=Running \
  --no-headers &lt;span class="o"&gt;|&lt;/span&gt; wc -l &lt;span class="o"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results for k8s always on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"baseline_cpu_request_per_pod=%s\n"&lt;/span&gt; &lt;span class="s2"&gt;"$BASELINE_CPU_REQUEST"&lt;/span&gt;
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"baseline_memory_request_per_pod=%s\n"&lt;/span&gt; &lt;span class="s2"&gt;"$BASELINE_MEMORY_REQUEST"&lt;/span&gt;

&lt;span class="nv"&gt;baseline_cpu_request_per_pod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50m
&lt;span class="nv"&gt;baseline_memory_request_per_pod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;64Mi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results for Substrate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;baseline_cpu_request_per_pod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50m
&lt;span class="nv"&gt;baseline_memory_request_per_pod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;64Mi
&lt;span class="nv"&gt;substrate_worker_cpu_request_per_pod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50m
&lt;span class="nv"&gt;substrate_worker_memory_request_per_pod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;64Mi
&lt;span class="nv"&gt;baseline_total_cpu_request_millicores&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2500
&lt;span class="nv"&gt;baseline_total_memory_request_mib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3200
&lt;span class="nv"&gt;substrate_total_cpu_request_millicores&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;250
&lt;span class="nv"&gt;substrate_total_memory_request_mib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;320
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above shows the requested-capacity savings:&lt;/p&gt;

&lt;p&gt;Kubernetes baseline: 50 Pods * 50m CPU / 64Mi = 2500m CPU / 3200Mi&lt;/p&gt;

&lt;p&gt;Substrate: 5 Pods * 50m CPU / 64Mi = 250m CPU / 320Mi&lt;/p&gt;

&lt;p&gt;Which results in a &lt;strong&gt;90%&lt;/strong&gt; reduction!&lt;/p&gt;

&lt;p&gt;You can also capture actual CPU and memory usage if &lt;code&gt;metrics-server&lt;/code&gt; is installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl top pods -n &lt;span class="s2"&gt;"$BENCHMARK_NAMESPACE"&lt;/span&gt; \
  -l cost-comparison/model=always-on-kubernetes &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

kubectl top pods -n ate-demo-counter &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7fru2na24o6kmgb9z89k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7fru2na24o6kmgb9z89k.png" alt=" " width="471" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice how many resources are saved with just a few Substrate deployments (on the bottom) vs k8s running workloads (50 pods, 50 agents).&lt;/p&gt;

&lt;p&gt;The Kubernetes baseline is running one always-on Pod per logical workload. With&lt;code&gt;ACTOR_COUNT=50&lt;/code&gt;, that means 50 &lt;code&gt;k8s-counter-*&lt;/code&gt; Pods are running even when they are mostly idle. Each baseline Pod has explicit CPU and memory requests, so the always-on capacity grows linearly with the number of logical workloads.&lt;/p&gt;

&lt;p&gt;The Substrate side is running the same logical workload count as actors, but only the worker pool stays hot. In this run, the counter WorkerPool has 5 &lt;code&gt;counter-deployment-*&lt;/code&gt; Pods. Each worker Pod has explicit CPU and memory requests, so the requested always-on capacity grows with worker count, not Actor count.&lt;/p&gt;

&lt;p&gt;The main difference is the always-on footprint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kubernetes baseline: 50 running workload PodsAgent Substrate:     5 running worker Pods for 50 logical actors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your result shows the core optimization: 50 idle logical workloads do not require50 always-on workload Pods when they run as Substrate actors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>programming</category>
      <category>kubernetes</category>
      <category>googlecloud</category>
    </item>
    <item>
      <title>Agent Substrate: Building Actors and Workers</title>
      <dc:creator>Michael Levan</dc:creator>
      <pubDate>Sat, 06 Jun 2026 19:19:49 +0000</pubDate>
      <link>https://dev.to/thenjdevopsguy/agent-substrate-building-actors-and-workers-4221</link>
      <guid>https://dev.to/thenjdevopsguy/agent-substrate-building-actors-and-workers-4221</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;In this blog post, you will learn how to set up Agent Substrate Actors and Workers to ensure agentic efficiency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow along from a hands-on perspective, you will need the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GKE or Kind cluster (due to the needs for Pod Certificates).&lt;/li&gt;
&lt;li&gt;Substrate installed. You can follow the guide here to do so.&lt;/li&gt;
&lt;li&gt;Clone the Substrate repo (demos and such that can be run from there).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you don't have a cluster readily available, you can follow along from a theoretical perspective and configure it at a later time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tldr; What Is Substrate?
&lt;/h2&gt;

&lt;p&gt;API/management plane + k8s Worker Nodes.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;With Substrate, you have Workers (Kubernetes Pods) and Actors (Agents running inside said Pods).&lt;/p&gt;

&lt;p&gt;More here: &lt;a href="https://www.cloudnativedeepdive.com/agent-substrate-the-agentic-ai-isolation-layer-on-k8s/" rel="noopener noreferrer"&gt;https://www.cloudnativedeepdive.com/agent-substrate-the-agentic-ai-isolation-layer-on-k8s/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy The Substrate Demo
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WorkerPool&lt;/code&gt; == the pool of warm k8s Pods that actors get multiplexed onto.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ActorTemplate&lt;/code&gt; == the immutable Actor definition/schema. Substrate builds the snapshot from it so new Actors hydrate instantly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deploy the demo.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./hack/install-ate.sh --deploy-demo-counter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Ensure that the golden snapshot is ready.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;wait&lt;/span&gt; --for=condition=Ready actortemplate/counter \
  -n ate-demo-counter --timeout=5m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Check to see that al resources are created.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get workerpool,actortemplate -n ate-demo-counter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create An Actor
&lt;/h2&gt;

&lt;p&gt;With the Actor Template and Worker Pool in place, you can now create an Actor from the snapshotted template.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an Actor.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate create actor my-counter-1 --template ate-demo-counter/counter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll notice that the Actor starts in a &lt;code&gt;SUSPENDED&lt;/code&gt; state as there hasn't been any traffic sent to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl ate get actor my-counter-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next section, you'll send traffic to the Actor to see it used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test The Actor
&lt;/h2&gt;

&lt;p&gt;The first step is to port-forward the router. The route in Substrate routes to Actors by a specific DNS name: &lt;code&gt;&amp;lt;actor-id&amp;gt;.actors.resources.substrate.ate.dev&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Within the terminal, port-forward the router.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl port-forward -n ate-system svc/atenet-router 8000:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In another terminal, test the connectivity by sending a request to it.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST -H &lt;span class="s2"&gt;"Host: my-counter-1.actors.resources.substrate.ate.dev"&lt;/span&gt; \
  http://localhost:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first request triggers an on-demand &lt;code&gt;resume&lt;/code&gt;. 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.&lt;/p&gt;

&lt;p&gt;Congrats! You have officially tested and ensured that Actors (Agents) work within your Substrate cluster.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>googlecloud</category>
      <category>kubernetes</category>
    </item>
  </channel>
</rss>
