# Kubernetes AI Agent - Kagent

## \*Clickbait warning, of course I will, but it’s cool you don’t have to!

Sorry, that’s quite misleading! However, I’ve been experimenting with Kagent on my local Kubernetes development cluster, and it’s really neat!

I could have done with something like this during my on-call SRE days!

## Kubernetes without the kubectl!

My old colleague and fellow Kubernetes enthusiast Chris Matcham suitably inspired me to give this a try. Colour me intrigued!

I followed Chris’ [guide here](https://chrismatcham.dev/Deploying-a-K8S-ninja-using-kagent-MCP-with-ArgoCD-&-Helm/) now. I didn’t have any credit on OpenAI ChatGPT, so I wanted to try it using Google’s Gemini as my AI backend

## Not a quick start-ish

So I’m not going to go over installing Kagent, Chris’ post already does a great job of that. Use Helm, use ArgoCD, however you like.

As I’m planning on using Google Gemini as my AI backend I will add what I did differently to help get you started.

First, I manually added a Kubernetes Secret in my kagent-agent namespace. I need to add my API key as a secret. So you can head over to Google AI Studio to get yourself an API key and associate it with a Google Cloud Project. I had a personal Google Cloud project I was already using for some personal dev things so was ready to go.

Then create your secret.

I then opted to install using ArgoCD to deploy. I had it running anyway. I just used the UI for testing purposes, just make sure to install the Kagent CRDs first.

Head over to aistudio.google.com and hit create API key and associate it with a Google Cloud project you have access to, then add some values to create the Gemini provider as part of the Helm deployment:

We’ll set up ArgoCD like this:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750425381855/119852b7-699c-4361-b1af-234571ed34f8.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750425436754/f87164c1-3f7a-492b-a9bb-47ed83d3630f.png align="center")

We’re telling Helm to include the Kubernetes secret I created manually that has the API key I just created.

To create the application in ArgoCD, I could have created a declarative yaml file (Chris does a great job of this in his blog post), but as I’m just tinkering with this, I’m opting for the UI.

The repo URL I’m using is [ghcr.io/kagent-dev/kagent/helm](http://ghcr.io/kagent-dev/kagent/helm) and the charts for the CRDs are kagent-crds version: 0.3.15 and I’m using the same Helm repo URL and the chart name kagent for the agent deployment using version 0.3.15

Syncronise the ArgoCD application and I should have 2 running applications, 1 for the CRDs and another for the actual agent

I’m using Rancher Desktop for my local cluster, so with a quick port forward of the agent service resource and I can now access my Kagent deployment. Let’s head over to the models to make sure my changes to configure the model to Gemini worked:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750425614569/85d5bcc5-7c66-4cba-98a1-b2fb69b0732f.png align="center")

Let’s open a chat and take it for a spin!

I created a deployment manually using the terminal, so let’s test if Kagent can see what’s running on the cluster:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750426043915/5242aa71-4085-4ef9-9c14-0ab7dee73d7d.png align="center")

Nice! I can interact with the cluster without using kubectl!

Let’s try something else, let’s create a pod

```bash
kubectl run something-wrong --image ngiinx:latest
```

Let’s see if it spots it…

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750433331783/3d107d52-cd7e-4a21-913d-a2d5f758deeb.png align="center")

It’s noticed that there is an incorrectly configured pod!

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750433399947/f3f98d46-50b2-4617-b336-039dfc71ff29.png align="center")

Before I can even ask, it’s fixed the incorrect image.

What is interesting is that I’ve had different outcomes from this type of issue I’ve asked to look into.

Sometimes it’s given me the “I’ve found you’ve configured the image Nginx which doesn’t look right, you should correct it“ to it correcting it, not telling me, then when I ask “Whats wrong with my pod?“ it starts going diving into Kubelet and networking possibilities because another pod is working so its probably not that type thing.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1750438614829/f451b787-bcec-4f42-8d08-8122d67e99f2.jpeg align="center")

*In case no one’s noticed, I’m a big Simpsons and Futurama fan…*

I have tried this by creating an agent that only has read access on the cluster, so it can’t make changes.

If you're implementing using GitOps, ArgoCD etc, then that might be for the best, and using Kagnet as a troubleshooting tool.

Imagine waking up at 3 am thanks to Pager duty and you’ve got an AI assistant to summarise logs and spot things that don’t look right? Game changer! What I would have given for this type of thing when I was an on-call SRE getting alerts at 2 am!

AI Agents are the new hot jam, I’m really keen to investigate and try this out a bit more as it’s quite new to me, potentially have something like this running for my Homelab to help troubleshoot etc.

My good pal Chris does a great job getting you started with his walkthrough [here](https://chrismatcham.dev/Deploying-a-K8S-ninja-using-kagent-MCP-with-ArgoCD-&-Helm/). I just tried it out with a Google Cloud Gemini twist.

You can find out more about Kagent in more detail and its thriving community at their [website.](https://kagent.dev/docs/kagent/introduction/installation)
