Skip to content

Commit 7d8f750

Browse files
authored
Support agentgateway standalone sidecar (kubernetes-sigs#2905)
* Support agentgateway standalone sidecar Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io> * Update standalone agentgateway chart tests Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io> --------- Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>
1 parent 62b845e commit 7d8f750

6 files changed

Lines changed: 47 additions & 148 deletions

File tree

config/charts/epplib/templates/_helpers.tpl

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,23 @@ Return the standalone EPP model-server target ports.
150150
{{- end -}}
151151

152152
{{/*
153-
Return the agentgateway model Service ports.
153+
Return the agentgateway logical model backend name.
154154
*/}}
155-
{{- define "gateway-api-inference-extension.agentgateway.modelServicePorts" -}}
156-
{{- $sidecarValues := .Values.inferenceExtension.sidecar | default dict -}}
157-
{{- $agentgateway := index $sidecarValues "agentgateway" | default dict -}}
158-
{{- $service := index $agentgateway "service" | default dict -}}
159-
{{- include "gateway-api-inference-extension.normalizedPortList" (dict "path" ".Values.inferenceExtension.sidecar.agentgateway.service.ports" "value" (index $service "ports")) -}}
155+
{{- define "gateway-api-inference-extension.agentgateway.logicalBackendName" -}}
156+
{{- $selector := .Values.inferenceExtension.endpointsServer.endpointSelector | default "" -}}
157+
{{- $appName := "" -}}
158+
{{- range $raw := splitList "," $selector -}}
159+
{{- $part := trim $raw -}}
160+
{{- $kv := splitList "=" $part -}}
161+
{{- if and (eq (len $kv) 2) (eq (trim (index $kv 0)) "app") -}}
162+
{{- $appName = trim (index $kv 1) -}}
163+
{{- end -}}
164+
{{- end -}}
165+
{{- if not (empty $appName) -}}
166+
{{- $appName -}}
167+
{{- else -}}
168+
{{- .Release.Name -}}
169+
{{- end -}}
160170
{{- end -}}
161171

162172
{{/*
@@ -201,40 +211,13 @@ Return the rendered sidecar ConfigMap data.
201211
{{- toYaml $data -}}
202212
{{- end -}}
203213

204-
{{/*
205-
Render labels from the standalone endpoint selector for the generated model Service.
206-
Only equality-based selectors are supported because Service selectors are a map.
207-
*/}}
208-
{{- define "gateway-api-inference-extension.agentgateway.modelServiceSelectorLabels" -}}
209-
{{- $selector := .Values.inferenceExtension.endpointsServer.endpointSelector | default "" -}}
210-
{{- if empty $selector -}}
211-
{{- fail ".Values.inferenceExtension.endpointsServer.endpointSelector is required when creating an agentgateway model Service" -}}
212-
{{- end -}}
213-
{{- range $raw := splitList "," $selector }}
214-
{{- $part := trim $raw -}}
215-
{{- $kv := splitList "=" $part -}}
216-
{{- if ne (len $kv) 2 -}}
217-
{{- fail (printf ".Values.inferenceExtension.endpointsServer.endpointSelector must use comma-separated key=value labels when creating an agentgateway model Service, got %q" $selector) -}}
218-
{{- end -}}
219-
{{- $key := trim (index $kv 0) -}}
220-
{{- $value := trim (index $kv 1) -}}
221-
{{- if or (empty $key) (empty $value) -}}
222-
{{- fail (printf ".Values.inferenceExtension.endpointsServer.endpointSelector must use non-empty key=value labels when creating an agentgateway model Service, got %q" $selector) -}}
223-
{{- end -}}
224-
{{- printf "%s: %s\n" ($key | quote) ($value | quote) -}}
225-
{{- end -}}
226-
{{- end -}}
227-
228214
{{/*
229215
Render the default standalone agentgateway sidecar config template.
230216
*/}}
231217
{{- define "gateway-api-inference-extension.sidecar.agentgatewayConfig" -}}
232-
{{- $sidecarValues := .Values.inferenceExtension.sidecar | default dict -}}
233-
{{- $agentgateway := index $sidecarValues "agentgateway" | default dict -}}
234-
{{- $service := index $agentgateway "service" | default dict -}}
235-
{{- $serviceName := index $service "name" | default "" -}}
236-
{{- $serviceNamespace := index $service "namespace" | default .Release.Namespace -}}
237-
{{- $servicePorts := splitList "," (include "gateway-api-inference-extension.agentgateway.modelServicePorts" .) -}}
218+
{{- $serviceName := include "gateway-api-inference-extension.agentgateway.logicalBackendName" . -}}
219+
{{- $serviceNamespace := .Release.Namespace -}}
220+
{{- $servicePorts := splitList "," (include "gateway-api-inference-extension.standaloneEndpointTargetPorts" .) -}}
238221
{{- $backendPort := index $servicePorts 0 -}}
239222
{{- $listenerPort := include "gateway-api-inference-extension.standaloneProxyListenerPort" . | int -}}
240223
config:

config/charts/standalone/templates/_validations.tpl

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,19 @@ standalone validations
1919
{{- if not (or (eq $proxyType "envoy") (eq $proxyType "agentgateway")) -}}
2020
{{- fail (printf ".Values.inferenceExtension.sidecar.proxyType must be one of [envoy, agentgateway], got %q" $proxyType) -}}
2121
{{- end -}}
22-
{{- if eq $proxyType "agentgateway" -}}
22+
{{- if eq $proxyType "agentgateway" -}}
2323
{{- if and .Values.inferenceExtension.endpointsServer .Values.inferenceExtension.endpointsServer.createInferencePool -}}
24-
{{- fail ".Values.inferenceExtension.endpointsServer.createInferencePool=false is required when proxyType=agentgateway; standalone agentgateway currently supports only service-backed routing" -}}
24+
{{- fail ".Values.inferenceExtension.endpointsServer.createInferencePool=false is required when proxyType=agentgateway; standalone agentgateway uses EPP endpoint discovery with a logical service backend" -}}
2525
{{- end -}}
26-
{{- $agentgateway := index $sidecar "agentgateway" | default dict -}}
27-
{{- $service := index $agentgateway "service" | default dict -}}
28-
{{- $serviceName := index $service "name" | default "" -}}
29-
{{- $serviceCreate := index $service "create" | default true -}}
30-
{{- if hasKey $service "port" -}}
31-
{{- fail ".Values.inferenceExtension.sidecar.agentgateway.service.port has been replaced by .Values.inferenceExtension.sidecar.agentgateway.service.ports" -}}
26+
{{- if hasKey $sidecar "agentgateway" -}}
27+
{{- fail ".Values.inferenceExtension.sidecar.agentgateway is no longer supported; standalone agentgateway derives its logical backend from endpointsServer settings" -}}
3228
{{- end -}}
33-
{{- if empty $serviceName -}}
34-
{{- fail ".Values.inferenceExtension.sidecar.agentgateway.service.name is required when proxyType=agentgateway" -}}
35-
{{- end -}}
36-
{{- $targetPorts := include "gateway-api-inference-extension.standaloneEndpointTargetPorts" . -}}
37-
{{- $servicePorts := include "gateway-api-inference-extension.agentgateway.modelServicePorts" . -}}
38-
{{- if ne $targetPorts $servicePorts -}}
39-
{{- fail (printf ".Values.inferenceExtension.sidecar.agentgateway.service.ports must match .Values.inferenceExtension.endpointsServer.targetPorts when proxyType=agentgateway, got service ports %q and target ports %q" $servicePorts $targetPorts) -}}
40-
{{- end -}}
41-
{{- $listenerPort := include "gateway-api-inference-extension.standaloneProxyListenerPort" . -}}
29+
{{- $_ := include "gateway-api-inference-extension.standaloneEndpointTargetPorts" . -}}
30+
{{- $_ := include "gateway-api-inference-extension.standaloneProxyListenerPort" . -}}
4231
{{- $flags := .Values.inferenceExtension.flags | default dict -}}
4332
{{- if and (hasKey $flags "secure-serving") (ne (toString (index $flags "secure-serving")) "false") -}}
4433
{{- fail ".Values.inferenceExtension.flags.secure-serving must be false when proxyType=agentgateway; standalone agentgateway uses plaintext gRPC to EPP over localhost" -}}
4534
{{- end -}}
46-
{{- if $serviceCreate -}}
47-
{{- $selectorLabels := include "gateway-api-inference-extension.agentgateway.modelServiceSelectorLabels" . -}}
48-
{{- end -}}
4935
{{- end -}}
5036
{{- end -}}
5137
{{- end -}}

config/charts/standalone/templates/agentgateway-service.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

config/charts/standalone/values.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ inferenceExtension:
3030
enabled: true
3131
proxyType: envoy
3232

33-
# Agentgateway-specific settings used by the built-in preset when
34-
# proxyType=agentgateway. service.name is required.
35-
agentgateway:
36-
service:
37-
create: true
38-
name: ""
39-
namespace: ""
40-
# Must match inferenceExtension.endpointsServer.targetPorts.
41-
ports:
42-
- 8000
43-
4433
# Built-in standalone proxy presets. The selected preset is merged with the
4534
# top-level sidecar.* fields below, so explicit user overrides still win.
4635
presets:

hack/verify-helm.sh

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ test_cases_standalone["basic"]="--set inferenceExtension.endpointsServer.endpoin
9797
test_cases_standalone["gke-provider"]="--set provider.name=gke --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false"
9898
test_cases_standalone["latency-predictor"]="--set inferenceExtension.latencyPredictor.enabled=true --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false"
9999
test_cases_standalone["inferencepool"]="--set inferenceExtension.endpointsServer.createInferencePool=true --set inferencePool.modelServers.matchLabels.app=llm-instance-gateway"
100-
test_cases_standalone["agentgateway"]="--set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8000' --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.endpointsServer.targetPorts[0]=8000'"
100+
test_cases_standalone["agentgateway"]="--set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false"
101101

102102

103103
echo "Processing dependencies for standalone chart..."
@@ -136,42 +136,21 @@ if eval "${invalid_proxy_command}"; then
136136
exit 1
137137
fi
138138

139-
missing_agentgateway_service_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set inferenceExtension.sidecar.proxyType=agentgateway >/dev/null"
140-
echo "Executing: ${missing_agentgateway_service_command}"
141-
if eval "${missing_agentgateway_service_command}"; then
142-
echo "Helm template unexpectedly succeeded for missing agentgateway service.name"
143-
exit 1
144-
fi
145-
146-
unsupported_agentgateway_inferencepool_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8000' --set inferenceExtension.endpointsServer.createInferencePool=true --set inferencePool.modelServers.matchLabels.app=llm-instance-gateway >/dev/null"
139+
unsupported_agentgateway_inferencepool_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.endpointsServer.createInferencePool=true --set inferencePool.modelServers.matchLabels.app=llm-instance-gateway >/dev/null"
147140
echo "Executing: ${unsupported_agentgateway_inferencepool_command}"
148141
if eval "${unsupported_agentgateway_inferencepool_command}"; then
149142
echo "Helm template unexpectedly succeeded for unsupported agentgateway createInferencePool=true configuration"
150143
exit 1
151144
fi
152145

153-
unsupported_agentgateway_selector_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8000' --set inferenceExtension.endpointsServer.endpointSelector='app in (llm-instance-gateway)' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.endpointsServer.targetPorts[0]=8000' >/dev/null"
154-
echo "Executing: ${unsupported_agentgateway_selector_command}"
155-
if eval "${unsupported_agentgateway_selector_command}"; then
156-
echo "Helm template unexpectedly succeeded for unsupported agentgateway model Service selector"
157-
exit 1
158-
fi
159-
160-
mismatched_agentgateway_ports_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8001' --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.endpointsServer.targetPorts[0]=8000' >/dev/null"
161-
echo "Executing: ${mismatched_agentgateway_ports_command}"
162-
if eval "${mismatched_agentgateway_ports_command}"; then
163-
echo "Helm template unexpectedly succeeded for mismatched agentgateway service.ports"
164-
exit 1
165-
fi
166-
167-
unsupported_agentgateway_listener_port_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8000' --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.endpointsServer.targetPorts[0]=8000' --set 'inferenceExtension.extraServicePorts[0].name=proxy' --set 'inferenceExtension.extraServicePorts[0].port=9000' --set 'inferenceExtension.extraServicePorts[0].protocol=TCP' --set 'inferenceExtension.extraServicePorts[0].targetPort=9000' >/dev/null"
146+
unsupported_agentgateway_listener_port_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.extraServicePorts[0].name=proxy' --set 'inferenceExtension.extraServicePorts[0].port=9000' --set 'inferenceExtension.extraServicePorts[0].protocol=TCP' --set 'inferenceExtension.extraServicePorts[0].targetPort=9000' >/dev/null"
168147
echo "Executing: ${unsupported_agentgateway_listener_port_command}"
169148
if eval "${unsupported_agentgateway_listener_port_command}"; then
170149
echo "Helm template unexpectedly succeeded without an agentgateway listener Service port named http"
171150
exit 1
172151
fi
173152

174-
mismatched_agentgateway_listener_target_port_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8000' --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.endpointsServer.targetPorts[0]=8000' --set 'inferenceExtension.extraServicePorts[0].name=http' --set 'inferenceExtension.extraServicePorts[0].port=9000' --set 'inferenceExtension.extraServicePorts[0].protocol=TCP' --set 'inferenceExtension.extraServicePorts[0].targetPort=9001' >/dev/null"
153+
mismatched_agentgateway_listener_target_port_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.extraServicePorts[0].name=http' --set 'inferenceExtension.extraServicePorts[0].port=9000' --set 'inferenceExtension.extraServicePorts[0].protocol=TCP' --set 'inferenceExtension.extraServicePorts[0].targetPort=9001' >/dev/null"
175154
echo "Executing: ${mismatched_agentgateway_listener_target_port_command}"
176155
if eval "${mismatched_agentgateway_listener_target_port_command}"; then
177156
echo "Helm template unexpectedly succeeded for an agentgateway listener targetPort that does not match port"
@@ -190,7 +169,7 @@ fi
190169

191170
echo "Verifying standalone agentgateway renders plaintext EPP and custom listener ports..."
192171
agentgateway_render_output="${TEMP_DIR}/standalone-agentgateway-render.yaml"
193-
agentgateway_render_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.sidecar.agentgateway.service.name=llm-instance-gateway --set 'inferenceExtension.sidecar.agentgateway.service.ports[0]=8000' --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.endpointsServer.targetPorts[0]=8000' --set 'inferenceExtension.extraServicePorts[0].name=http' --set 'inferenceExtension.extraServicePorts[0].port=9000' --set 'inferenceExtension.extraServicePorts[0].protocol=TCP' --set 'inferenceExtension.extraServicePorts[0].targetPort=http' > ${agentgateway_render_output}"
172+
agentgateway_render_command="${SCRIPT_ROOT}/bin/helm template ${SCRIPT_ROOT}/config/charts/standalone --set inferenceExtension.sidecar.proxyType=agentgateway --set inferenceExtension.endpointsServer.endpointSelector='app=llm-instance-gateway' --set inferenceExtension.endpointsServer.createInferencePool=false --set 'inferenceExtension.extraServicePorts[0].name=http' --set 'inferenceExtension.extraServicePorts[0].port=9000' --set 'inferenceExtension.extraServicePorts[0].protocol=TCP' --set 'inferenceExtension.extraServicePorts[0].targetPort=http' > ${agentgateway_render_output}"
194173
echo "Executing: ${agentgateway_render_command}"
195174
eval "${agentgateway_render_command}"
196175
if ! grep -q -- '--secure-serving=false' "${agentgateway_render_output}"; then
@@ -213,14 +192,19 @@ if ! grep -q -- 'destinationMode: passthrough' "${agentgateway_render_output}";
213192
echo "Agentgateway Helm template did not render passthrough destination mode"
214193
exit 1
215194
fi
216-
217-
agentgateway_service_block="${TEMP_DIR}/standalone-agentgateway-service.yaml"
218-
sed -n '/^# Source: standalone\/templates\/agentgateway-service.yaml/,/^---/p' "${agentgateway_render_output}" > "${agentgateway_service_block}"
219-
if ! grep -q -- 'app.kubernetes.io/component: agentgateway-model-service' "${agentgateway_service_block}"; then
220-
echo "Agentgateway model Service did not render its component label"
195+
if ! grep -q -- 'name: "default/llm-instance-gateway"' "${agentgateway_render_output}"; then
196+
echo "Agentgateway Helm template did not derive the logical backend name from endpointSelector"
197+
exit 1
198+
fi
199+
if ! grep -q -- 'hostname: "llm-instance-gateway"' "${agentgateway_render_output}"; then
200+
echo "Agentgateway Helm template did not derive the logical backend hostname from endpointSelector"
201+
exit 1
202+
fi
203+
if grep -q -- 'standalone/templates/agentgateway-service.yaml' "${agentgateway_render_output}"; then
204+
echo "Agentgateway Helm template unexpectedly rendered a model Service"
221205
exit 1
222206
fi
223-
if grep -q -- 'app.kubernetes.io/name:' "${agentgateway_service_block}"; then
224-
echo "Agentgateway model Service rendered an app.kubernetes.io/name label"
207+
if grep -q -- 'agentgateway-model-service' "${agentgateway_render_output}"; then
208+
echo "Agentgateway Helm template unexpectedly rendered model Service labels"
225209
exit 1
226210
fi

0 commit comments

Comments
 (0)