fix: set appProtocol on agent Services for A2A discovery#1297
fix: set appProtocol on agent Services for A2A discovery#1297syn-zhu wants to merge 1 commit intokagent-dev:mainfrom
Conversation
The kagent controller creates a Service for each Agent CR but does not set appProtocol on the port. Without appProtocol: kgateway.dev/a2a, AgentGateway's A2A plugin cannot discover agent Services, forcing traffic through the controller's passthrough proxy which drops HTTP headers (including traceparent). Set appProtocol: kgateway.dev/a2a on the agent Service port so AgentGateway can route directly to agent pods, preserving all headers and enabling end-to-end distributed tracing. Closes kagent-dev#1295 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Agent manifest translation so that the Kubernetes Service created for each Agent CR sets an explicit appProtocol, enabling AgentGateway’s A2A plugin to discover and route directly to agent Services (preserving HTTP headers for distributed tracing).
Changes:
- Set
spec.ports[0].appProtocol: kgateway.dev/a2aon the per-Agent Service port.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Name: "http", | ||
| Port: dep.Port, | ||
| TargetPort: intstr.FromInt(int(dep.Port)), | ||
| AppProtocol: ptr.To("kgateway.dev/a2a"), |
There was a problem hiding this comment.
Adding AppProtocol changes the serialized Service manifest; the golden test outputs under go/internal/controller/translator/agent/testdata/outputs/*.json currently expect the Service port to only have name/port/targetPort and will fail until they’re regenerated/updated to include appProtocol: "kgateway.dev/a2a" on the Service port(s).
| Name: "http", | |
| Port: dep.Port, | |
| TargetPort: intstr.FromInt(int(dep.Port)), | |
| AppProtocol: ptr.To("kgateway.dev/a2a"), | |
| Name: "http", | |
| Port: dep.Port, | |
| TargetPort: intstr.FromInt(int(dep.Port)), |
Summary
appProtocol: kgateway.dev/a2aon the Service port created for each Agent CRWithout
appProtocol, AgentGateway's A2A plugin cannot discover agent Services.This forces traffic through the kagent controller's passthrough proxy, which drops
HTTP headers (including
traceparent), breaking distributed trace continuity.With this one-line fix, AgentGateway can route directly to agent pods, preserving
all headers and enabling end-to-end tracing.
Test plan
kubectl get svc <agent> -o jsonpath='{.spec.ports[0].appProtocol}'returnskgateway.dev/a2atraceparentheader through gateway, verify trace continuity in backendCloses #1295
🤖 Generated with Claude Code