Skip to content

Conversation

@npolshakova
Copy link
Contributor

@npolshakova npolshakova commented May 2, 2025

Description

This feature adds integration between kgateway and AgentGateway, enabling users to configure AgentGateway as a data plane for agent-to-agent (A2A) and Model Context Protocol (MCP) traffic. The new syncer translates Gateway API resources into AgentGateway xDS-compatible Listener and Target configurations.

API changes

NONE

Code changes

  • Added new syncer to translate Gateway resources into AgentGateway Listener and Target configuration.
  • Added Helm chart values to enable AgentGateway integration.
  • Added deployment template for agentgateway
  • Added GatewayParameters value to enable AgentGateway deployer integration

CI changes

  • New unit setup test
  • New e2e test with sample MCP server and A2A agent running in k8s

Docs changes

Context

Enhancement Proposal: #11152

Interesting decisions

The self managed gateway status can't be updated by the proxy syncer (since the deployment is self managed). The old behavior would block the syncer from sending updates because the status was in an invalid state. Open to suggestions what the behavior should be (skip statuses for self-managed gateways, use an "unknown" status, partially report, etc.)

Testing steps

You can manually verify the integration with the following steps:

  1. Setup:

Setup cluster and package helm chart:

AGENTGATEWAY=true ./hack/kind/setup-kind.sh

Install:

kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/standard-install.yaml

helm upgrade -i -n kgateway-system kgateway-crds ./_test/kgateway-crds-1.0.0-ci1.tgz --create-namespace

helm upgrade -i -n kgateway-system kgateway ./_test/kgateway-1.0.0-ci1.tgz --create-namespace --set agentGateway.enabled=true  --set image.registry=ghcr.io/kgateway-dev
  1. Apply config
k apply -f /Users/ninapolshakova/solo/kgateway/test/kubernetes/e2e/features/agentgateway/testdata/mcp.yaml
k apply -f /Users/ninapolshakova/solo/kgateway/test/kubernetes/e2e/features/agentgateway/testdata/a2a.yaml
k apply -f /Users/ninapolshakova/solo/kgateway/test/kubernetes/e2e/features/agentgateway/testdata/agentgateway.yaml
k apply -f /Users/ninapolshakova/solo/kgateway/test/kubernetes/e2e/features/agentgateway/testdata/gateway-mcp-a2a.yaml

For the mcp tool discovery, you can also use this mcp setup with AgentGateway:

kubectl apply -f- <<EOF
# Deployment Manifest for the MCP Proxy
apiVersion: apps/v1
kind: Deployment
metadata:
  name: github
  labels:
    app: github
spec:
  replicas: 1
  selector:
    matchLabels:
      app: github
  template:
    metadata:
      labels:
        app: github
    spec:
      containers:
        - name: github
          image: ghcr.io/agentgateway/agentgateway:latest-ext
          args:
            - -f
            - /etc/agentgateway/config.json
          ports:
            - containerPort: 3000
          volumeMounts:
            - name: github-config
              mountPath: /etc/agentgateway/config.json
              subPath: config.json
      volumes:
        - name: github-config
          configMap:
            name: github-config
---
apiVersion: v1
kind: Service
metadata:
  name: github
spec:
  selector:
    app: github
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
      appProtocol: kgateway.dev/mcp
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: github-config
data:
  config.json: |
    {
      "type": "static",
      "listeners": [
        {
          "name": "sse",
          "protocol": "MCP",
          "sse": {
            "address": "[::]",
            "port": 3000
          }
        }
      ],
      "targets": {
        "mcp": [
          {
            "name": "github",
            "stdio": {
              "cmd": "npx",
              "args": [
                "-y",
                "@modelcontextprotocol/server-github"
              ],
              "env": {
                "GITHUB_PERSONAL_ACCESS_TOKEN": "fake"
              }
            }
          }
        ]
      }
    }
EOF
  1. Test the UI:
    Port-forward the UI dashboard:
kubectl port-forward services/agent-gateway 19000:19000

Port-forward the Gateway listener (9090 for a2a, 8080 for mcp):

kubectl port-forward services/agent-gateway 9090:9090

Then navigate to the playground in the UI:
Screenshot 2025-05-06 at 3 57 55 PM

If you port-forward 8080, you should also be able to use the MCP server in the playground:
image

You can also test the deployer behavior for agentgateway (where kgateway creates the proxy deployment based on the k8s gateway api resource):

 helm upgrade -i -n kgateway-system kgateway ./_test/kgateway-1.0.0-ci1.tgz --create-namespace --values /Users/ninapolshakova/solo/kgateway/test/kubernetes/e2e/tests/manifests/agent-gateway-integration.yaml

Then apply:

kind: GatewayParameters
apiVersion: gateway.kgateway.dev/v1alpha1
metadata:
  name: kgateway
spec:
  kube:
    agentGateway:
      enabled: true
---
kind: GatewayClass
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: agentgateway
spec:
  controllerName: kgateway.dev/kgateway
  parametersRef:
    group: gateway.kgateway.dev
    kind: GatewayParameters
    name: kgateway
    namespace: default
---
kind: Gateway
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: agent-gateway
spec:
  gatewayClassName: agentgateway
  listeners:
    - protocol: kgateway.dev/mcp
      port: 8080
      name: mcp
      allowedRoutes:
        namespaces:
          from: All
    - protocol: kgateway.dev/a2a
      port: 9090
      name: a2a
      allowedRoutes:
        namespaces:
          from: All

You can also scope the gateway to either allow from any namespace or only the namespace the Gateway is defined via allowedRoutes.

Notes for reviewers

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Change Type

/kind new_feature

Changelog

Enables kgateway to act as the control plane for [agentgateway](https://agentgateway.dev/). 

Signed-off-by: npolshakova <[email protected]>
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from 529e77d to b4acbe3 Compare May 6, 2025 21:43
@npolshakova npolshakova marked this pull request as ready for review May 6, 2025 21:44
Copilot AI review requested due to automatic review settings May 6, 2025 21:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds integration between kgateway and AgentGateway by introducing a new syncer to translate Gateway API resources into AgentGateway xDS configurations for both A2A and MCP traffic. The changes include new e2e tests, updates to Helm chart values, and modifications in internal controller and proxy syncer components to support the integration.

Reviewed Changes

Copilot reviewed 24 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/kubernetes/e2e/features/agentgateway/* Added new end-to-end tests for AgentGateway integration
internal/kgateway/extensions2/settings/settings.go Added a new settings field to enable AgentGateway integration
internal/kgateway/proxy_syncer/proxy_syncer.go Minor comment fix in the proxy syncer logic
internal/kgateway/agentgatewaysyncer/* New syncer and supporting proto files for AgentGateway functionality
internal/kgateway/krtcollections/setup.go Updated type registration to include rest config for new collections
Files not reviewed (3)
  • Makefile: Language not supported
  • hack/kind/setup-kind.sh: Language not supported
  • test/kubernetes/e2e/features/agentgateway/a2a-example/Dockerfile: Language not supported

Signed-off-by: npolshakova <[email protected]>
Signed-off-by: npolshakova <[email protected]>

github action

Signed-off-by: npolshakova <[email protected]>
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from 3b85fc7 to 2ecefd8 Compare May 7, 2025 17:28
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from 1ea2711 to 88f3669 Compare May 8, 2025 17:08
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from bf272d2 to 3966be8 Compare May 8, 2025 18:35
Copy link
Contributor

@EItanya EItanya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna leave the syncer changes to other who are more familiar with the code

Signed-off-by: npolshakova <[email protected]>
Signed-off-by: npolshakova <[email protected]>

separate agentgateway proto gen

Signed-off-by: npolshakova <[email protected]>
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from b075b87 to cab759b Compare May 9, 2025 19:23
Signed-off-by: npolshakova <[email protected]>
Signed-off-by: npolshakova <[email protected]>
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from 2876361 to 0929383 Compare May 19, 2025 18:11
Signed-off-by: npolshakova <[email protected]>
Signed-off-by: npolshakova <[email protected]>
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from 3ba437a to 238bdb4 Compare May 19, 2025 19:06
@npolshakova npolshakova requested a review from jenshu May 19, 2025 19:28
Signed-off-by: npolshakova <[email protected]>
@npolshakova npolshakova force-pushed the agent-gateway-integration branch from 1638598 to 7a0af56 Compare May 19, 2025 19:31
Copy link
Contributor

@jenshu jenshu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved with non-blocking comments

@npolshakova npolshakova added this pull request to the merge queue May 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch May 19, 2025
@npolshakova npolshakova added this pull request to the merge queue May 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch May 19, 2025
@npolshakova npolshakova added Type: Enhancement New feature or request kind/feature Categorizes issue or PR as related to a new feature. labels May 19, 2025
@npolshakova npolshakova requested a review from jenshu May 19, 2025 21:59
@npolshakova npolshakova enabled auto-merge May 19, 2025 22:03
@npolshakova npolshakova added this pull request to the merge queue May 19, 2025
Merged via the queue into kgateway-dev:main with commit 0fb3754 May 19, 2025
20 checks passed
@npolshakova npolshakova deleted the agent-gateway-integration branch May 19, 2025 22:45
@npolshakova npolshakova mentioned this pull request Jul 15, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note Type: Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants