Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Routing LLM inference traffic with Istio and InferencePool

By updated

Improve this page

In front of a language model server, a Kubernetes Service sends requests without looking at the queue or the cache of each replica: a saturated replica keeps receiving them. The Gateway API Inference Extension fixes this. An InferencePool groups the replicas, and an endpoint picker chooses, request by request, the one that must answer, based on its metrics. This lesson shows it with Istio 1.32.0 and a simulated model server, with no GPU, on three replicas of which one is saturated. It is for readers who already operate a Gateway and need to route inference traffic through it.

What you will learn

  • Explain why a Service distributes inference requests badly.
  • Say what the InferencePool and the endpoint picker add to a Service.
  • Check that the Inference Extension is enabled in Istio.
  • Declare an InferencePool and route an HTTPRoute to it.
  • Read the distribution of requests according to the replicas' load.
  • Diagnose a route that does not reach the pool.

Prerequisites

  • The Gateway API over HTTPS lesson, which installs Istio 1.32 in ambient mode, presents the Istio Gateway, the ClusterIP annotation and how to read a Gateway's conditions. This lesson reuses them without detailing them again.
  • The Gateway API lesson for Gateway and HTTPRoute.
  • The Serving an LLM: batching and throughput lesson (in French), which explains the KV cache and the load of an inference server. The next section recaps the essentials.

Why does a Service distribute inference traffic badly?

An inference request can last a few hundred milliseconds or several seconds, depending on the length of the text sent and of the text generated. A Service, for its part, knows neither the queue nor the cache of its replicas. Two states of a replica nevertheless change everything: the length of its queue, and the fill rate of its KV cache, the memory where the server keeps the context of each request in progress.

A replica whose queue holds 40 requests and whose cache is 97% full answers slowly, but a Service does not see it.

Behind an Istio Gateway, the proxy distributes by default according to the number of requests in progress on each replica (the LEAST_REQUEST algorithm), not according to the server's queue or cache. When requests are short and sent one at a time, this number stays close to zero everywhere. With three replicas, the saturated replica therefore receives a share close to the others'. This lesson's measurement, further down, confirms it: behind an ordinary Service, it receives 8 requests out of 30, or 27%. This share can drop if many requests arrive at the same time, because a slow replica accumulates them.

To avoid this, the Gateway must know the state of each replica at the moment the request arrives.

What do the InferencePool and the endpoint picker change?

The InferencePool is the equivalent of a Service for inference: it groups the model's Pods with a label selector and a port. It adds a designation, endpointPickerRef, which points to a Service, the endpoint picker. This picker reads the replicas' metrics and tells the Gateway which one must take each request.

On the diagram below, first follow the arrow from the picker to the replicas: the metrics are read outside the request. Then follow the client's request: the decision is made on every request.

Exchange between four actors. Continuously, the endpoint picker reads the queue and the KV cache of the model's replicas. When a client sends a POST /v1/completions request to the Istio Gateway, the Gateway asks the picker which replica takes this request. The picker answers with a free replica, the Gateway forwards the request to it, and the replica answers the client with the x-inference-pod header.Model replicasEndpoint pickerIstio GatewayClientreads queue length andKV cachePOST /v1/completionswhich replica takes thisrequest?a free replicaforwards the request to the chosen replicaresponse with the x-inference-pod header
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The HTTPRoute no longer targets a Service: its backendRef designates the InferencePool, which triggers the picker lookup.

Which versions does the demonstration use?

The demonstration runs on the kubeadm cluster of the lab catalog, measured on 2026-11-16. Istio is on version 1.32.0 there, in ambient mode, Kubernetes on v1.37.2 and the Gateway API on v1.6.1. The endpoint picker is the Inference Extension image registry.k8s.io/gateway-api-inference-extension/epp:v1.5.0@sha256:86c679b057298e68c6e65ff5603e92066d432e77b11f1f81f0a06399694810bc, and the simulated model server is ghcr.io/llm-d/llm-d-inference-sim:v0.7.1@sha256:74211b5dbf27a867fcefae92067701e0a5fcee827f95156d89718bf3e1bfb845. The InferencePool type comes from a Gateway API extension, installed by a CRD whose annotation gives the version.

Terminal window
istioctl version
kubectl get crd inferencepools.inference.networking.k8s.io -o jsonpath='{.metadata.annotations.inference\.networking\.k8s\.io/bundle-version}{"\n"}'
client version: 1.32.0
control plane version: 1.32.0
data plane version: 1.32.0 (3 proxies)
v1.5.0-rc.2

The lab installs the published v1.5.0 version of the extension, the one Istio 1.32.0 embeds in its code. The manifests.yaml file of this version nevertheless still carries the v1.5.0-rc.2 mention in the inference.networking.k8s.io/bundle-version annotation, hence the output above. The lab installs four CRDs of the extension, all from this file. Only InferencePool is in API version v1: the other three are still alpha.

inferencemodelrewrites.inference.networking.x-k8s.io bundle-version=v1.5.0-rc.2 versions=v1alpha2
inferenceobjectives.inference.networking.x-k8s.io bundle-version=v1.5.0-rc.2 versions=v1alpha2
inferencepoolimports.inference.networking.x-k8s.io bundle-version=v1.5.0-rc.2 versions=v1alpha1
inferencepools.inference.networking.k8s.io bundle-version=v1.5.0-rc.2 versions=v1

The Istio 1.32 documentation suggests something else: it installs v1.0.1 of the extension, with kubectl kustomize "github.com/kubernetes-sigs/gateway-api-inference-extension/config/crd?ref=v1.0.1". What the documentation says and what the lab installs are two distinct facts. As of 2026-11-16, the latest published version of the extension is v1.6.2; the lab stays on v1.5.0, the version Istio 1.32.0 is compiled against. To reproduce this lesson, install v1.5.0: its manifests.yaml file contains the four CRDs, and nothing else.

Terminal window
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api-inference-extension/releases/download/v1.5.0/manifests.yaml

Another version of the CRDs does not necessarily have the same fields. Before reusing an example found online, compare the version of the manifests you applied with that of the example. The bundle-version annotation helps, but it can lag behind the version, as here.

How do you enable the Inference Extension in Istio?

For Istio to understand the backendRef of an InferencePool, the ENABLE_GATEWAY_API_INFERENCE_EXTENSION environment variable of its control plane (pilot, in the istiod Deployment) must be true. The Istio 1.32 documentation sets the two variables SUPPORT_GATEWAY_API_INFERENCE_EXTENSION and ENABLE_GATEWAY_API_INFERENCE_EXTENSION at installation, with --set values.pilot.env.SUPPORT_GATEWAY_API_INFERENCE_EXTENSION=true and --set values.pilot.env.ENABLE_GATEWAY_API_INFERENCE_EXTENSION=true. The lab cluster has already set both; the following command reads them.

Terminal window
kubectl -n istio-system set env deploy/istiod --list | grep -i INFERENCE
ENABLE_GATEWAY_API_INFERENCE_EXTENSION=true
SUPPORT_GATEWAY_API_INFERENCE_EXTENSION=true

The grep -i filter keeps only these two variables. What happens if the extension is switched off? Set ENABLE_GATEWAY_API_INFERENCE_EXTENSION to false, let istiod redeploy, then recreate the pool, the Gateway and the route to the pool. The route is accepted, but its reference to the pool does not resolve, and a request fails. The HTTPRoute conditions say where:

Accepted=True reason=Accepted message=Route was valid
ResolvedRefs=False reason=InvalidKind message=InferencePool is not enabled. To enable, set ENABLE_GATEWAY_API_INFERENCE_EXTENSION to true in istiod
ResolvedWaypoints=True reason=ResolvedWaypoints message=All waypoints resolved

Read ResolvedRefs=False: the reason is InvalidKind and the message names the variable to set to true, while Accepted stays True. The InferencePool itself has no condition (its status.parents is empty). A request sent through the Gateway receives HTTP/1.1 500 Internal Server Error, with server: istio-envoy and content-length: 0.

The istiod log says nothing about the extension: the only lines that mention inference designate the Gateway's namespace, for configuration pushes and the Gateway's reconciliation. The ResolvedRefs condition message is therefore the only clue. The false value of ENABLE_GATEWAY_API_INFERENCE_EXTENSION is enough to switch the extension off. Set it back to true to restore the setup, and also set SUPPORT_GATEWAY_API_INFERENCE_EXTENSION, as the Istio documentation does.

How do you declare the InferencePool and the route?

The lab's model server runs in the inference namespace. It is a vLLM simulator, with no GPU, that answers the /v1/completions API on port 8000. It is made of two Deployments, modele-libre (two replicas) and modele-sature (one replica), all labeled app: modele. The endpoint picker, a Deployment and a Service named selecteur, listens on port 9002. These manifests are deployed by the lab, when you launch dsoxlab run k8s-router-des-requetes-d-inference: outside the lab, the rest of the lesson can be read, but not replayed as is.

Terminal window
kubectl -n inference get pods -l app=modele -L charge

On the demonstration cluster, the two modele-libre replicas carry the suffixes 2h55w and 9szdf, the modele-sature one the suffix qzc74: the suffixes change with every installation. The CHARGE column is a lab label, which is libre or saturee and exists only to show you which of the three replicas is saturated.

The pool does not read this label: it takes all three replicas, the saturated one included, through app: modele. Excluding the saturated one by hand would be a frozen choice, while the load changes from one minute to the next. It is up to the picker to avoid it by reading its metrics, and it can only avoid a replica it sees.

apiVersion: inference.networking.k8s.io/v1
kind: InferencePool
metadata:
name: pool-modele
namespace: inference
spec:
selector:
matchLabels:
app: modele
targetPorts:
- number: 8000
endpointPickerRef:
name: selecteur
port:
number: 9002

In this lab, the endpoint picker is launched to wait for an InferencePool named pool-modele: it stays not ready as long as this pool does not exist. Once the pool is created, the selecteur Deployment becomes ready.

The Gateway and the route reuse what the previous lesson showed. The Gateway carries an HTTP listener on port 80 and the ClusterIP annotation, since the cluster has no load balancer. The route designates the pool in backendRefs, with its group and its kind.

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: passerelle-ia
namespace: inference
annotations:
networking.istio.io/service-type: ClusterIP
spec:
gatewayClassName: istio
listeners:
- name: http
port: 80
protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: route-modele
namespace: inference
spec:
parentRefs:
- name: passerelle-ia
sectionName: http
rules:
- backendRefs:
- group: inference.networking.k8s.io
kind: InferencePool
name: pool-modele

A backendRef to an ordinary Service, in place of the pool, would not consult the endpoint picker. Apply the three objects, then read them. kubectl -n inference rollout status deploy/selecteur waits for the picker to become ready.

Terminal window
kubectl -n inference get inferencepool,gateway,httproute
NAME AGE
inferencepool.inference.networking.k8s.io/pool-modele 16s
NAME CLASS ADDRESS PROGRAMMED AGE
gateway.gateway.networking.k8s.io/passerelle-ia istio passerelle-ia-istio.inference.svc.cluster.local True 16s
NAME HOSTNAMES AGE
httproute.gateway.networking.k8s.io/route-modele 16s

Look at PROGRAMMED True on the Gateway: the cluster has indeed programmed it. Once the pool was created, the picker became ready, which rollout status confirms with deployment "selecteur" successfully rolled out.

How do you read the distribution of requests?

Each response from the simulator carries the x-inference-pod header, which gives the name of the Pod that served it. The simulator sets this header, on every response, even when called directly, with no Gateway or Service: it therefore does not prove that the picker chose. What proves it is the distribution, meaning the number of requests received by the saturated replica.

The command below sends thirty requests to the ClusterIP address of the Service Istio creates for the Gateway. It reads it itself into the IP variable; the CLUSTER-IP column of kubectl -n inference get svc -l gateway.networking.k8s.io/gateway-name=passerelle-ia gives the same address. The text changes with every request, because the picker can also favor the replica that has already seen the same beginning of text (this is its prefix scorer, which tries to reuse the cache that is already filled): identical texts would skew the measurement.

Terminal window
IP=$(kubectl -n inference get svc -l gateway.networking.k8s.io/gateway-name=passerelle-ia -o jsonpath='{.items[0].spec.clusterIP}'); for i in $(seq 1 30); do curl -s -o /dev/null -D - --max-time 20 -H 'Content-Type: application/json' -d "{\"model\":\"meta-llama/Llama-3.1-8B-Instruct\",\"prompt\":\"Pool $i $(date +%s%N)\",\"max_tokens\":8}" http://$IP/v1/completions | tr -d '\r' | grep -i '^x-inference-pod:'; done | sort | uniq -c
20 x-inference-pod: modele-libre-6cbb5d7f6d-2h55w
10 x-inference-pod: modele-libre-6cbb5d7f6d-9szdf

Count the lines: 20 + 10 = 30, so each request got an answer from a replica, since a request left unanswered would show no header. This command does not display the HTTP code: the validation, described further down, requires a 200 code. 20 responses come from one free replica and 10 from the other. The saturated replica, modele-sature-69c5787c54-qzc74 on this installation, does not appear: it receives 0 requests.

The saturated replica is not slower than the others, because its metrics are simulated (--fake-metrics: 40 requests waiting, KV cache at 97%). It is the picker that avoids it by reading these metrics, not a real delay.

What does an ordinary Service give behind the same Gateway?

To compare, you keep the Gateway and replace the route's backendRef with an ordinary Service placed in front of the same three replicas. The route stays accepted, only the destination changes.

Terminal window
kubectl -n inference apply -f - <<'EOF'
apiVersion: v1
kind: Service
metadata:
name: modele
namespace: inference
spec:
selector:
app: modele
ports:
- port: 8000
targetPort: 8000
EOF
kubectl -n inference patch httproute route-modele --type=json -p '[{"op":"replace","path":"/spec/rules/0/backendRefs/0","value":{"kind":"Service","name":"modele","port":8000}}]'

Rerun the same loop of thirty requests. The table puts the two recorded distributions side by side.

Route destinationFree 2h55wFree 9szdfSaturated qzc74
InferencePool pool-modele20100
Ordinary modele Service9138 (27%)

Look at the last column: behind the Service, the saturated replica receives 8 requests out of 30, a share close to the others'. Behind the pool, it receives 0. The numbers 20 and 10 are not equal: the choice follows the metrics, not a round robin. Your distribution between the two free replicas will differ; what matters is the saturated replica's share, at most 3 requests out of 30 for the lab to pass. In both cases, the 30 responses carry the x-inference-pod header: it does not distinguish the two setups.

How do you recognize a response that went through the picker?

A response that went through the pool carries two traces of its own, which the Service does not add. The processing of the picker's responses sets x-went-into-resp-headers: true, a header its code reserves for debugging, and the response arrives in transfer-encoding: chunked, whereas behind the Service it keeps a content-length. You read them with curl -D - on one request.

Terminal window
curl -s -o /dev/null -D - -H 'Content-Type: application/json' -d '{"model":"meta-llama/Llama-3.1-8B-Instruct","prompt":"entetes 1","max_tokens":8}' http://$IP/v1/completions | tr -d '\r'
HTTP/1.1 200 OK
x-envoy-upstream-service-time: 0
x-went-into-resp-headers: true
server: istio-envoy
content-type: application/json
x-inference-port: 8000
date: Mon, 16 Nov 2026 12:47:29 GMT
x-inference-pod: modele-libre-6cbb5d7f6d-2h55w
x-inference-namespace: inference
transfer-encoding: chunked

Look for x-went-into-resp-headers and transfer-encoding: chunked. Behind the ordinary Service, the same command returns content-length: 323 and neither of these two lines. To get back to the lab setup, put the backendRef back on the pool (the route's group, kind and name above) and delete the modele Service.

Troubleshooting

The route or the measurement does not give the expected result? The table goes from the symptom back to the cause, in the order in which it is quickest to check.

SymptomLikely causeFix
The request through the Gateway returns 500 Internal Server Error (content-length: 0) and the route carries Accepted=True with ResolvedRefs=False, reason InvalidKind, message InferencePool is not enabledENABLE_GATEWAY_API_INFERENCE_EXTENSION is false in istiod (the pool then has no condition and the istiod log does not mention the extension)Reread the variable in the istiod Deployment, set it to true, wait for the redeployment, then reread the route's ResolvedRefs condition
The route or the pool is refusedThe manifest uses fields from another version of the extension than the installed CRD (the lab installs v1.5.0, the Istio 1.32 documentation v1.0.1)Record the version of the manifests applied and the inference.networking.k8s.io/bundle-version annotation, compare them with the example's version, then reinstall the CRDs accordingly
The selecteur Deployment is never readyThe picker waits for an InferencePool named pool-modele that does not exist in inferenceCreate the pool, then reread kubectl logs deploy/selecteur -n inference
The Gateway stays not programmedIstio's LoadBalancer Service waits for a missing load balancerAdd the networking.istio.io/service-type: ClusterIP annotation
The saturated replica receives its share of requests (8 out of 30 behind a Service)The backendRef targets an ordinary Service, with no InferencePool group or kindSet group: inference.networking.k8s.io and kind: InferencePool in backendRefs, then look for x-went-into-resp-headers in a response
The responses carry x-inference-pod but the distribution stays blindThe header comes from the simulator, it is present even without a pickerCount the saturated replica's requests, and read x-went-into-resp-headers and transfer-encoding: chunked
The pool does not group the three replicasselector is too narrow and leaves a model Pod outCompare selector with the labels read by kubectl get pods -n inference --show-labels
The distribution concentrates on a single replicaThe requests send the same text, which the picker's prefix scorer favorsChange the text on every request during the measurement

Hands-on practice

The lab replays the lesson on the kubeadm cluster where Istio 1.32 runs in ambient mode with the extension enabled. You create the InferencePool that groups the three replicas of the simulated model and designates the endpoint picker, a Gateway of class istio and an HTTPRoute whose backend is the pool.

The validation reads the pool, checks that its selector takes exactly the three replicas, that the picker is ready, that the Gateway is programmed and that the route to the pool is accepted. It then sends thirty completion requests. A response counts as served when its code is 200 and the x-inference-pod header names one of the three replicas. At least 27 served responses are required and at most 3 for the saturated replica, or 10% of the 30 requests. With the pool's distribution (30 served, 0 for the saturated one), the test passes. With that of an ordinary Service (30 served, 8 for the saturated one), it fails on the second threshold.

Key takeaways

  • A Service reads neither the queue nor the KV cache: a saturated replica keeps receiving requests.
  • An InferencePool groups the model's Pods and designates, through endpointPickerRef, the picker that chooses the replica request by request.
  • The HTTPRoute targets the pool with group: inference.networking.k8s.io and kind: InferencePool, not a Service.
  • With ENABLE_GATEWAY_API_INFERENCE_EXTENSION set to false in pilot, the route stays Accepted=True but ResolvedRefs=False (InvalidKind, InferencePool is not enabled), and the Gateway answers 500.
  • The lab installs v1.5.0 of the extension, whereas the Istio 1.32 documentation installs v1.0.1: compare the version of your manifests with that of an example found online before reusing it.
  • The pool must contain all the replicas, the saturated one included: the picker only avoids, request by request, the replicas it sees.
  • The x-inference-pod header comes from the simulator, even without a picker: the proof is the distribution, 0 requests for the saturated replica behind the pool against 8 out of 30 behind an ordinary Service. The picker's own trace is x-went-into-resp-headers: true, with a response in transfer-encoding: chunked.
  • The distribution is measured on requests whose text changes.

Knowledge check

Eight prediction and diagnosis questions: the distribution by a Service, the role of the endpoint picker, Istio's variable, the pool's content, the text that changes in the measurement, a picker that is never ready, a pool's backendRef and reading the distribution.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
8 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer