You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. Create a `Gateway` resource that agentgateway manages. KServe attaches `HTTPRoute` resources to this gateway automatically for each `InferenceService` you deploy.
28
+
2. Create a `Gateway` resource that agentgateway manages. KServe attaches
29
+
`HTTPRoute` resources to this gateway automatically for each
4. Verify that the KServe `LLMInferenceService` controller is available.
106
+
107
+
```shell
108
+
kubectl wait --for=condition=available \
109
+
deployment/llmisvc-controller-manager \
110
+
-n kserve \
111
+
--timeout=180s
112
+
kubectl get deployment llmisvc-controller-manager -n kserve
94
113
```
95
114
96
115
Example output:
97
116
98
117
```
99
-
deployment.apps/kserve-controller-manager condition met
100
-
NAME READY UP-TO-DATE AVAILABLE AGE
101
-
kserve-controller-manager 1/1 1 1 45s
118
+
deployment.apps/llmisvc-controller-manager condition met
119
+
NAME READY UP-TO-DATE AVAILABLE AGE
120
+
llmisvc-controller-manager 1/1 1 1 45s
102
121
```
103
122
104
123
## Step 4: Deploy a mocked LLM with llm-d-inference-sim
@@ -111,29 +130,89 @@ Instead of a real model, this guide uses [llm-d-inference-sim](https://github.co
111
130
kubectl create namespace kserve-test
112
131
```
113
132
114
-
2. Deploy an `InferenceService` using llm-d-inference-sim directly via `spec.predictor.containers`. This approach bypasses KServe's model runtime machinery entirely, no `ClusterServingRuntime` or model storage is needed.
133
+
2. Create an `{{< reuse "agw-docs/snippets/backend.md" >}}` that points
134
+
to the workload service that KServe creates for the
135
+
`LLMInferenceService`. The backend identifies the endpoint as an
136
+
OpenAI-compatible LLM so that agentgateway can apply LLM-aware features.
## Optional Step 4b: Apply a transformation policy to the KServe-generated HTTPRoute
154
250
155
251
Without a policy, agentgateway forwards requests and responses as-is. This
156
252
step shows how a transformation policy can enrich responses with additional
157
253
headers — without touching the inference service itself.
158
254
159
-
1. Verify that KServe created an HTTPRoute after the Gateway becomes `READY`. The route attaches to `kserve/kserve-ingress-gateway` with hostname `mock-llm-kserve-test.example.com`.
255
+
1. Verify that KServe created an HTTPRoute after the
256
+
`LLMInferenceService` becomes `Ready`. The route attaches to
257
+
`kserve/kserve-ingress-gateway` with hostname
258
+
`mock-llm-kserve-test.example.com`.
160
259
161
260
```shell
162
-
kubectl get httproute mock-llm -n kserve-test -o yaml
261
+
kubectl get httproute mock-llm-kserve-route -n kserve-test -o yaml
163
262
```
164
263
165
264
{{< tabs >}}
166
265
{{% tab name="Cloud Provider LoadBalancer" %}}
167
266
2. Get the external address of the gateway and save it in an environment variable.
168
267
```shell
169
-
export INGRESS_GW_ADDRESS=$(kubectl get svc -n kserve agentgateway-proxy \
268
+
export INGRESS_GW_ADDRESS=$(kubectl get svc -n kserve kserve-ingress-gateway \
@@ -203,7 +302,7 @@ headers — without touching the inference service itself.
203
302
targetRefs:
204
303
- group: gateway.networking.k8s.io
205
304
kind: HTTPRoute
206
-
name: mock-llm
305
+
name: mock-llm-kserve-route
207
306
traffic:
208
307
transformation:
209
308
response:
@@ -275,7 +374,7 @@ headers — without touching the inference service itself.
275
374
targetRefs:
276
375
- group: gateway.networking.k8s.io
277
376
kind: HTTPRoute
278
-
name: mock-llm
377
+
name: mock-llm-kserve-route
279
378
traffic:
280
379
transformation:
281
380
response:
@@ -311,72 +410,21 @@ headers — without touching the inference service itself.
311
410
{{< /tabs >}}
312
411
313
412
314
-
## Step 5: Create a backend
315
-
316
-
KServe generates the `HTTPRoute` with a plain Kubernetes `Service` as the `backendRef`. However, to apply a token-based rate limiting policy, agentgateway needs the backend to be an {{< reuse "agw-docs/snippets/backend.md" >}}. This way, agentgateway knows that the backend is an LLM that has a response body with the `usage.total_tokens` field to count against the rate limit bucket. In the following steps, you create an {{< reuse "agw-docs/snippets/backend.md" >}} and a second HTTPRoute to route to it as a workaround to the KServe-created, Service-based setup.
317
-
318
-
1. Create an `{{< reuse "agw-docs/snippets/backend.md" >}}` that points at the llm-d-inference-sim service.
2. Create a second `HTTPRoute` that routes to the `{{< reuse "agw-docs/snippets/backend.md" >}}`. This route uses the same hostname as the KServe-generated route but matches only the `/v1/chat/completions` path, so the gateway prefers it for LLM traffic.
How token counting works: Agentgateway reads `usage.total_tokens` from the JSON response body returned by the inference service. Each request deducts that many tokens from the bucket. When the bucket empties, subsequent requests receive `429 Too Many Requests` until the next fill interval.
472
520
473
-
1. Apply an {{< reuse "agw-docs/snippets/policy.md" >}} that caps requests at **70 tokens per minute**. The policy targets the `mock-llm-ai` route that selects the `{{< reuse "agw-docs/snippets/backend.md" >}}`.
521
+
1. Apply an {{< reuse "agw-docs/snippets/policy.md" >}} that caps
522
+
requests at **70 tokens per minute**. The policy targets the KServe-generated
0 commit comments