Step-by-step guide to install and configure KAgent on Kubernetes, manage ModelConfig and provider secrets, enable tools and k8s-agent, and interact via UI and kagent CLI.
This guide walks through a progressive installation and configuration of KAgent on Kubernetes. You’ll learn how to:
Install KAgent CRDs and the KAgent Helm chart.
Store LLM provider secrets and create a ModelConfig CRD.
Install KAgent with a minimal configuration, then enable the built-in tools and the k8s-agent.
Interact with the Kubernetes agent via the KAgent UI and the kagent CLI.
Inspect controller logs and observe agent-driven actions (e.g., creating manifests).
Prerequisites, example commands, and troubleshooting tips are included. Ensure you have a Kubernetes cluster, kubectl, helm, and the kagent CLI (if invoking agents from the terminal). Also set any referenced environment variables (for example, OPENAI_API_KEY) in your shell.
The KAgent Helm charts are published to an OCI registry on GitHub: oci://ghcr.io/kagent. Install the CRDs into the kagent namespace (the namespace will be created if missing):
# Adjust the chart path and flags as needed for your environmenthelm install kagent-crds oci://ghcr.io/kagent --namespace kagent --create-namespace
Verify CRDs were created before continuing:
kubectl get crds | grep kagentkubectl -n kagent get namespaces
Store your OpenAI API key in a Kubernetes generic secret in the kagent namespace. The examples and ModelConfig below reference the secret name kagent-openai and the key OPENAI_API_KEY.
export OPENAI_API_KEY="sk-..." # set to your actual keykubectl create secret generic kagent-openai \ --from-literal=OPENAI_API_KEY="$OPENAI_API_KEY" \ -n kagent
KAgent uses a ModelConfig CRD to reference LLM provider credentials and model preferences. Create a ModelConfig YAML that points to the secret you created. Example:
Start with a minimal Helm values file that disables optional agents, tools, and MCP servers so you can enable them progressively. Save this as 01-values.min.yaml:
To access the KAgent UI from your workstation in this lab, change the kagent-ui Service type to NodePort and bind a node port (e.g., 3080).Edit the service:
kubectl -n kagent edit svc kagent-ui
Modify the spec to include a nodePort and set type: NodePort. Example fragment:
Use the KAgent UI to start a conversation with the k8s-agent. The right-side tool pane displays tools the agent may call (for example, GetResources which performs kubectl-like queries). From the UI ask:“What are the pods running in kagent namespace?”The agent will call the GetResources tool and return a pod list consistent with kubectl -n kagent get pods.
You can invoke the agent from the CLI for scripted or reproducible workflows. Example:
kagent invoke -n kagent \ -a k8s-agent \ -t "list all pods in the kagent namespace" \ -S
-S requests a streaming response (controller streams JSON status updates and final results).
Modify the text prompt to target different namespaces or resources:
kagent invoke -n kagent -a k8s-agent -t "list the pods in default namespace" -S
Controller logs will reflect task creation and execution. Example log excerpt:
{"level":"info","ts":"2025-12-15T10:28:21Z","logger":"http.tasks-handler","msg":"Successfully created task","operation":"create-task","task_id":"45d63c46-a37a-4c16-9a2a-18693efa8cae"}{"level":"info","ts":"2025-12-15T10:28:21Z","logger":"http","msg":"Request completed","method":"POST","path":"/api/tasks","status":201}{"level":"info","ts":"2025-12-15T10:28:21Z","logger":"http","msg":"Request completed","method":"POST","path":"/api/a2a/kagent/k8s-agent/","status":200}
11) Example: Ask agent to create a Service manifest (agent-driven action)
Agents can generate and apply manifests. For example, ask the k8s-agent to create a ClusterIP Service (without a selector) in the default namespace:
kagent invoke -n kagent -a k8s-agent \ -t "create a service ssdfsdflkjdipin in default namespace of type ClusterIP without any selector" \ -S -o json \ | jq -r 'select(.status? and .status.message? and .status.message.parts?) | .status.message.parts[]? | select(.kind=="data" and .data.name!=null) | .data.name'
The above jq pipeline extracts tool names used in the response (for example, k8s_apply_manifest). After the agent finishes, verify the Service exists:
kubectl get svc -n default
Sample output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEkubernetes ClusterIP 172.20.0.1 <none> 443/TCP 62mssdfsdflkjdipin ClusterIP None <none> <none> 28s
If the UI or agent responses are not immediately available, allow a few seconds for pods to become ready and refresh the UI. Agents and tools often take a short time to initialize after a Helm upgrade.
This completes the lab for progressively installing KAgent, adding a ModelConfig, enabling built-in tools and the k8s-agent, and interacting via the UI and CLI. Additional topics you can explore next include MCP servers and deploying custom MCP configurations using KAgent.