Skip to main content
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.

Prerequisites


1) Install the KAgent CRDs

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):
Verify CRDs were created before continuing:

2) Create the OpenAI secret

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.
Verify the secret exists:

3) ModelConfig: store LLM provider details

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:
Key notes:
  • apiKeySecret must match the Kubernetes secret name.
  • apiKeySecretKey must match the key inside that secret (e.g., OPENAI_API_KEY).
  • openAI.baseUrl is optional. Omit it to use the public OpenAI endpoint or set it when using a proxy/private host.
Apply the ModelConfig and confirm it was created:
If you are using OpenAI’s public API, you can omit openAI.baseUrl. Use baseUrl only when routing through a proxy or private endpoint.

4) Install KAgent with a minimal values file

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:
Install or upgrade KAgent using that minimal configuration:
Check services in the kagent namespace:
You should see at least the controller and UI services (typically ClusterIP by default).

5) Expose the KAgent UI (NodePort)

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:
Modify the spec to include a nodePort and set type: NodePort. Example fragment:
After saving the edit, open the UI at http://localhost:3080 or http://<node-ip>:3080 depending on your cluster networking.

6) Inspect available provider ModelConfig examples

KAgent supports multiple providers (Anthropic, OpenAI, Groq, and more). Example snippets: Anthropic minimal example:
OpenAI full configuration example:
Note: Some CRD schemas expect temperature and topP as strings — keep them quoted if required.

7) Enable KAgent built-in tools

Enable the Tools Library by setting kagent-tools.enabled: true in a values file (for example, 02-values-tools.yaml) and upgrading the release:
Upgrade the release:
After the upgrade, the Tools Library in the UI should list many tools. Wait a few seconds and refresh the UI while pods start.
Screenshot of a web page for "kagent" showing a Tools Library with a search bar and a list of tool categories (Argo, Cilium, Datetime, Helm, Istio, K8s, Prometheus, etc.). A hand-cursor is hovering over the "Datetime" entry and the page shows "113 tools found."

8) Enable the k8s-agent

Enable the k8s-agent to add Kubernetes troubleshooting capabilities. Example values file 04-values-enable-agents.yaml:
Apply the change:
Watch pods start in the kagent namespace:
Sample output while the k8s-agent initializes:
After initialization the agent pod becomes Running:
Verify configured agents:
Example output:

9) Interact with the K8s agent via UI

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.
A screenshot of a web-based chat/agent interface for a Kubernetes AI agent (kagent/k8s-agent), showing a "Start a conversation" prompt and a message input asking "What are the pods running in kagent namespace?". The right sidebar lists various k8s tools and commands.

10) Invoke the agent via the kagent CLI

You can invoke the agent from the CLI for scripted or reproducible workflows. Example:
  • -S requests a streaming response (controller streams JSON status updates and final results).
  • Modify the text prompt to target different namespaces or resources:
Controller logs will reflect task creation and execution. Example log excerpt:

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:
The above jq pipeline extracts tool names used in the response (for example, k8s_apply_manifest). After the agent finishes, verify the Service exists:
Sample output:

Useful commands & troubleshooting

Use these commands to inspect KAgent resources, logs, and cluster events while debugging or verifying behavior.
Documentation and further examples:
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.

Watch Video