This guide demonstrates how to deploy a Question & Answer (Q&A) agent using Kagent. The agent leverages the qwen3-coder-plus model from Alibaba Cloud Model Studio and a fetch Model Context Protocol (MCP) service to retrieve and summarize web page content in real time.
Preparations
Create a namespace named kagent in your ACK cluster.
Install the
kagent-crdsandkagentapplications in thekagentnamespace from the ACK Marketplace or using .Activate the Alibaba Cloud Model Studio and create an API key.
Step 1: Create a ModelConfig
Get the KubeConfig of your cluster and use kubectl to connect to the cluster. If your cluster does not have public network access enabled, you can use Workbench to connect to the cluster over the internal network. On the Cluster Information page, click Manage Clusters Using Workbench in the upper-right corner.
Export your Model Studio API key as an environment variable and create a Secret in the
kagentnamespace.export PROVIDER_API_KEY=${Your_Model_Studio_API_Key} kubectl create secret generic bailian-apikey -n kagent --from-literal credential="$PROVIDER_API_KEY"Apply the following YAML to create the
ModelConfigresource. The provider is set toOpenAIbecause Model Studio exposes an OpenAI-compatible API.kubectl -n kagent apply -f - <<EOF apiVersion: kagent.dev/v1alpha2 kind: ModelConfig metadata: name: bailian-provider-config spec: model: qwen3-coder-plus apiKeySecret: bailian-apikey apiKeySecretKey: credential openAI: baseUrl: https://dashscope-intl.aliyuncs.com/compatible-mode/v1 provider: OpenAI EOF
Step 2: Deploy the fetch MCP server
Deploy the
fetchMCP server in your ACK cluster.kubectl -n kagent apply -f - <<EOF apiVersion: apps/v1 kind: Deployment metadata: name: streamablehttp-fetch-deployment spec: replicas: 1 selector: matchLabels: app: streamablehttp-fetch template: metadata: labels: app: streamablehttp-fetch spec: containers: - name: streamablehttp-fetch-container image: registry-cn-hangzhou.ack.aliyuncs.com/dev/streamablehttp-fetch:latest --- apiVersion: v1 kind: Service metadata: name: streamablehttp-fetch-service spec: selector: app: streamablehttp-fetch ports: - protocol: TCP port: 3000 targetPort: 3000 type: ClusterIP EOF
Step 3: Register the MCP Server
Create the
RemoteMCPServerresource to register the fetch service with Kagent. This tells the system how to communicate with the MCP server deployed in the previous step.kubectl -n kagent apply -f - <<EOF apiVersion: kagent.dev/v1alpha2 kind: RemoteMCPServer metadata: name: streamablehttp-fetch spec: description: A Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to Markdown for easier consumption. protocol: STREAMABLE_HTTP sseReadTimeout: 5m0s terminateOnClose: true timeout: 30s url: http://streamablehttp-fetch-service:3000/ EOFVerify that the MCP server is successfully registered and accepted.
kubectl get RemoteMCPServer -n kagentExpected output:
NAME PROTOCOL URL ACCEPTED streamablehttp-fetch STREAMABLE_HTTP http://streamablehttp-fetch-service:3000/ True
Step 4: Create the agent
Apply the Agent configuration.
kubectl -n kagent apply -f - <<EOF apiVersion: kagent.dev/v1alpha2 kind: Agent metadata: name: gateway-api-professor namespace: kagent spec: declarative: modelConfig: bailian-provider-config stream: true systemMessage: |- You are a friendly and helpful agent. Use the streamablehttp-fetch tool to get GatewayAPI information from the following URLs to answer user questions about GatewayAPI. # Links - intro: https://gateway-api.sigs.k8s.io/ - api-overview: https://gateway-api.sigs.k8s.io/concepts/api-overview/ - use-case: https://gateway-api.sigs.k8s.io/concepts/use-cases/ - servicemesh: https://gateway-api.sigs.k8s.io/mesh/ - implementations: https://gateway-api.sigs.k8s.io/implementations/ - v1.4 support overview: https://gateway-api.sigs.k8s.io/implementations/v1.4/ - Full spec, large page: https://gateway-api.sigs.k8s.io/reference/spec/ # Instructions - If a user's question is unclear, ask for clarification before running any tools. - Be friendly and enthusiastic in your responses to the user. - If you do not know how to answer a question, do not make up an answer. Reply with "Sorry, I don't know how to answer that question" and ask the user to clarify. - If the user asks for a summary or an overview, make sure to read the entire text before answering. # Response format - Always reply in Markdown format. - Your response must include a summary of the actions you performed and an explanation of the results. tools: - type: McpServer mcpServer: apiGroup: kagent.dev kind: RemoteMCPServer name: streamablehttp-fetch toolNames: - fetch description: This agent primarily answers questions related to the GatewayAPI specification. type: Declarative EOFVerify that the agent and dependent components are running.
kubectl get pod -n kagentExpected output:
NAME READY STATUS RESTARTS AGE gateway-api-professor-7cb6496b9d-l7nlj 1/1 Running 0 3m1s kagent-controller-794fc765df-hqswt 1/1 Running 0 45m kagent-ui-569cb875c6-h55mg 1/1 Running 0 45m streamablehttp-fetch-deployment-75d5cd86cf-h9rvp 1/1 Running 0 4m3s
Step 5: Access the agent
Kagent includes a built-in Web UI for interacting with the agent.
Use port forwarding to expose the
kagent-uiservice to your local machine.kubectl port-forward -n kagent service/kagent-ui 8082:8080Open your browser and navigate to
http://localhost:8082.Sample interaction 1: What are the APIs in the Gateway API?


Sample interaction 2: Which implementation currently has the most comprehensive support for Gateway API features?

