<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[KAI: AI-Powered Kubernetes assistant]]></title><description><![CDATA[KAI: AI-Powered Kubernetes assistant]]></description><link>https://kai-ai-powerered-ai-agent.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 26 Oct 2026 14:18:25 GMT</lastBuildDate><atom:link href="https://kai-ai-powerered-ai-agent.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[KAI: Building an AI-Powered Kubernetes Assistant for DevOps Automation]]></title><description><![CDATA[Since the release of OpenAI’s ChatGPT, everything suddenly became “AI this, AI that.” From LLMs writing essays to agents managing tasks, it felt like every…]]></description><link>https://kai-ai-powerered-ai-agent.hashnode.dev/kai-building-an-ai-powered-kubernetes-assistant-for-devops-automation</link><guid isPermaLink="true">https://kai-ai-powerered-ai-agent.hashnode.dev/kai-building-an-ai-powered-kubernetes-assistant-for-devops-automation</guid><dc:creator><![CDATA[Akash Jaiswal]]></dc:creator><pubDate>Wed, 25 Jun 2025 16:25:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1749989024295/a78806f0-e89b-4964-958d-76c73fec3a58.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-motivation">Motivation</h2>
<p>Since the release of OpenAI’s ChatGPT, everything suddenly became “AI this, AI that.” From LLMs writing essays to agents managing tasks, it felt like every day brought a new buzzword. Somewhere along the way, I stumbled upon MCP servers and AI agents — and I got curious.</p>
<p>As a DevOps engineer, I’ve spent my fair share of time fighting YAMLs, forgetting <code>kubectl</code> flags, and Googling how to fetch logs from a broken pod at 2 AM. So I thought — what if AI could help <em>here</em>? Not just write code, but actually help <strong>run and manage Kubernetes</strong>.</p>
<h2 id="heading-about-me">About me</h2>
<p>I'm Akash Jaiswal, a passionate engineer who wants to try and learn anything that I find interesting. One day I am reading about how compilers work and the other day I am Googling how to center a div.</p>
<p>I am an aviation geek and like discussing politics. I like traveling to new places, reading books, doomscrolling Twitter, and writing on Quora.</p>
<p>Yeah, trying my hands into photography as well :)</p>
<p><strong>Connect with me on</strong> <a target="_blank" href="https://github.com/jaiakash"><strong>GitHub</strong></a><strong>,</strong> <a target="_blank" href="https://www.linkedin.com/in/akashjaiswal03/"><strong>LinkedIn,</strong></a> <strong>or</strong> <a target="_blank" href="https://twitter.com/a_kashhhhhh_"><strong>Twitter.</strong></a></p>
<h2 id="heading-the-idea-kai">The Idea: KAI</h2>
<p>That’s when the idea hit me — can I build something that sits in my cluster and understands what I want in plain English? No YAMLs. No man pages. No “how do I scale a deployment” Stack Overflow searches.</p>
<p>So I started tinkering. I combined a local LLM, the MCP protocol, and my love for hacking around Kubernetes. The result? KAI — a small AI agent that translates human intent into <code>kubectl</code> magic.</p>
<p>This is the first part of KAI’s story. It’s still early, but I wanted to share the journey and get feedback. Maybe someone else out there is tired of remembering how to exec into a pod too :)</p>
<p>So sit back, relax and enjoy. Don't forget to check out the project and give your suggestions.</p>
<h2 id="heading-key-features">Key Features</h2>
<p>KAI sits on your cluster, ready to:</p>
<ul>
<li><p>Translate your plain English instructions into exact kubectl commands</p>
</li>
<li><p>Provide clear explanations and learning opportunities</p>
</li>
</ul>
<h3 id="heading-natural-language-understanding">🗣️ Natural Language Understanding</h3>
<pre><code class="lang-bash">&gt; KAI, find pods that aren<span class="hljs-string">'t running in the default namespace
Analyzing request... ✓
Command: kubectl get pods --namespace default --field-selector status.phase!=Running</span>
</code></pre>
<h3 id="heading-safety-first-approach">🛡️ Safety First Approach</h3>
<pre><code class="lang-bash">&gt; KAI, delete all pods
⚠️ Warning: This is a destructive operation!
Suggested safer alternative:
kubectl get pods --all-namespaces  <span class="hljs-comment"># Review pods first</span>
Use --namespace flag to target specific namespace
</code></pre>
<h3 id="heading-learning-opportunities">📚 Learning Opportunities</h3>
<pre><code class="lang-bash">&gt; [EXP] create a nodeport service
<span class="hljs-comment"># NodePort Service Creation</span>
A NodePort service exposes the application on a static port on each cluster node.
* Port range: 30000-32767
* Accessible from outside cluster
* Requires cluster node IP

Example <span class="hljs-built_in">command</span>:
kubectl create service nodeport nginx --tcp=80:80
</code></pre>
<h3 id="heading-real-time-execution">🔄 Real-time Execution</h3>
<pre><code class="lang-bash">&gt; Scale frontend deployment to 5 replicas
Validating... ✓
Current replicas: 3
Scaling... ⏳
Success! ✓
New replica count: 5
</code></pre>
<h2 id="heading-screenshots">Screenshots</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1750789881702/f81d0ee1-7879-4112-8526-5f0e286a5c70.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1750789877075/317c4d39-93ca-4757-836f-6c5f5e0d17b5.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-technical-deep-dive">Technical Deep Dive</h2>
<h3 id="heading-how-it-works">How It Works</h3>
<pre><code class="lang-mermaid">sequenceDiagram
    participant User
    participant KAI
    participant LLM
    participant K8s

    User-&gt;&gt;KAI: "Scale the frontend to 3 replicas"
    KAI-&gt;&gt;LLM: Analyze request &amp; generate command
    LLM--&gt;&gt;KAI: kubectl scale deployment frontend --replicas=3
    KAI-&gt;&gt;KAI: Validate operation
    KAI-&gt;&gt;K8s: Execute command
    K8s--&gt;&gt;KAI: Operation result
    KAI--&gt;&gt;User: Success confirmation &amp; explanation
</code></pre>
<p>The user sends a natural language input like “scale the frontend to 3 replicas.” KAI sends that to a local LLM (via MCP protocol), which returns the corresponding kubectl command. KAI validates the operation, runs it on the cluster, and returns a success message.</p>
<h3 id="heading-under-the-hood">Under the Hood</h3>
<p>Right now, the architecture is intentionally simple:</p>
<ul>
<li><p><strong>Go backend</strong>: Handles request parsing, validation, and <code>kubectl</code> execution</p>
</li>
<li><p><strong>Ollama LLM</strong>: Runs locally, no external APIs involved</p>
</li>
<li><p><strong>MCP Protocol</strong>: Used for consistent communication between KAI and LLM</p>
</li>
<li><p><strong>Kubeconfig-based access</strong>: Reads from the local kubeconfig to run commands inside the cluster</p>
</li>
</ul>
<p>Validation is basic for now (e.g., blocking dangerous commands like global pod deletes), but I plan to add more safety checks and dry-run support soon.</p>
<h3 id="heading-references-amp-inspiration">References &amp; Inspiration</h3>
<ul>
<li><p><a target="_blank" href="https://github.com/umeshkaul/using-ai-mcp-tools-for-troubleshooting-kubernetes">AI agent for k8s troubleshooting</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mark3labs/mcp-go">Go MCP SDK</a></p>
</li>
</ul>
<h2 id="heading-getting-started">Getting Started</h2>
<ol>
<li>Clone and setup:</li>
</ol>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/jaiakash/k8s-ai-agent
<span class="hljs-built_in">cd</span> k8s-ai-agent
go mod download
</code></pre>
<ol start="2">
<li>Start the server:</li>
</ol>
<pre><code class="lang-bash">go run server/server.go --kubeconfig=<span class="hljs-variable">$HOME</span>/.kube/config
</code></pre>
<ol start="3">
<li>In another terminal, start the client:</li>
</ol>
<pre><code class="lang-bash">go run client/client.go
</code></pre>
<h2 id="heading-future-roadmap">Future Roadmap</h2>
<h3 id="heading-short-term-goals">Short-term Goals</h3>
<ul>
<li><p>[ ] Cluster state awareness</p>
</li>
<li><p>[ ] Validate operations for safety</p>
</li>
<li><p>[ ] Execute commands with appropriate permissions</p>
</li>
<li><p>[ ] Learning from past interactions</p>
</li>
</ul>
<h3 id="heading-long-term-vision">Long-term Vision</h3>
<ul>
<li><p>[ ] Integration with popular CNCF tools</p>
</li>
<li><p>[ ] Advanced troubleshooting capabilities (<a target="_blank" href="https://github.com/k8sgpt-ai/k8sgpt">https://github.com/k8sgpt-ai/k8sgpt</a>)</p>
</li>
</ul>
<h2 id="heading-contributing">Contributing</h2>
<p>KAI is open source and welcomes contributions! Whether it's improving documentation, adding features, or reporting bugs, every contribution helps make Kubernetes more accessible.</p>
<hr />
<p><em>Found this interesting?</em> <a target="_blank" href="https://github.com/jaiakash/k8s-ai-agent"><strong><em>⭐ Star the repo</em></strong></a> <a target="_blank" href="https://github.com/jaiakash/k8s-ai-agent"><em>and share your</em></a> <em>thoughts!</em></p>
]]></content:encoded></item></channel></rss>