Skip to main content

Command Palette

Search for a command to run...

Kubernetes AI Agent - Kagent

I'm never using kubectl again!

Updated
4 min read
Kubernetes AI Agent - Kagent
F

Infrastructure Engineer with a Linux SysAdmin and SRE & DevOps background, previously a Google Cloud authorised trainer, who's excited and enthusiastic about Kubernetes, IaC, CI/CD, DevOps and SRE!

Experienced project infrastructure lead, project technical lead, and former Google Cloud Authorized trainer. Guiding organisations on cloud adoption, DevOps and SRE implementation. Mentor to junior engineers and people looking to change careers from a non-technical background or looking to get back into tech.

I'm passionate about building and deploying Cloud native infrastructure, automation, driving change and empowering people in learning and development.

*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 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:

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 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:

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:

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

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

kubectl run something-wrong --image ngiinx:latest

Let’s see if it spots it…

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

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.

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. 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.