Show HN: K8sAI – open-source GPT CLI tool for Kubernetes

https://github.com/wilson090/k8sAI

k8sAI

k8sAI is a RAG-enabled GPT that uses a vector store with the embeddings of the Kubernetes documentation. It can answer general questions about Kubernetes, explain output of provided kubectl commands, and suggested commands for you to then easily execute. Given an issue, it can also use kubectl commands to understand the issue and suggest a fix.

k8sAI has a few tools at its disposal that it can call to answer your questions and fix issues:

  • Execute_Kubectl_CMD_Tool - k8sAI can use this to execute kubectl read commands to gather more information about your cluster
  • Suggest_Kubectl_CMD_Tool - k8sAI uses this to suggest a kubectl command to you that you can then edit and execute
  • k8s_search - This tool is used by k8sAI to search k8s documentation to provide informed solutions

Note:

This tool sends data to OpenAI's servers. Please review the OpenAI API terms of use before using this tool.n This tool also executes kubectl commands. They are filtered to be read-only commands, but you provide explicit approval via (y/n) before every command executes.

Installation

Use the package manager pip to install k8sAI.

Configuration

Before using k8sAI, ensure your OpenAI API key is set as an environment variable (OPENAI_API_KEY).

Usage

Chat

To start a conversation with k8sAI:

Options:

  • -p, --prompt Provide an initial prompt to start the conversation (optional)
  • -t, --terminal Conversation will end after one response (optional)
  • --disable-execution Disable execution of kubectl commands (optional)

Explain

To have k8sAI explain the output of a Kubernetes command:

k8sAI explain --cmd='kubectl [command]' [OPTIONS]

Options:

  • -p, --prompt Provide an additional prompt to go along with the command output (optional)
  • -t, --terminal Conversation will end after one response (optional)
  • --disable-execution Disable execution of kubectl commands (optional)

Note: Only kubectl commands are valid for explanation.

Fix

To request k8sAI to suggest a fix based on a provided description of the problem:

If no prompt is provided, k8sAI will attempt to discover the problem itself (under development)

Options:

  • -p, --prompt A prompt describing the problem to analyze (optional)
  • -t, --terminal Conversation will end after one response (optional)
  • --disable-execution Disable execution of kubectl commands (optional)

Note: --disable-execution with signficantly reduce k8sAI's ability to discover a problem.

Common Commands

# Start a chat session with k8sAI
k8sAI chat
# Explain the output a specific kubectl command, end chat after first response
k8sAI explain --cmd='kubectl get pods' -t
# Suggest a fix for a described problem
k8sAI fix --prompt='Pods in `default` namespace are crashing frequently'

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This code is distributed under the AGPL v3 licensce.

{
"by": "wilson090",
"descendants": 7,
"id": 40237218,
"kids": [
40237361,
40237395,
40237255
],
"score": 9,
"text": "Hey HN!<p>I wanted to share an open-source project I’ve been working on called k8sAI. It’s a personal AI Kubernetes expert that can answer questions about your cluster, suggests commands, and even executes relevant kubectl commands to help diagnose and suggest fixes to your cluster, all in the CLI!<p>As a relative newcomer to k8s, this tool has really streamlined my workflow. I can ask questions about my cluster, k8sAI will run kubectl commands to gather info, and then answer those question. It’s also found several issues in my cluster for me - all I’ve had to do is point it in the right direction. I’ve really enjoyed making and using this so I thought it could be useful for others. Added bonus is that you don’t need to copy and paste into ChatGPT anymore!<p>k8sAI operates with read-only kubectl commands to make sure your cluster stays safe.<p>All you need is an OpenAI API key and a valid kubectl config. Start chatting with k8sAI using:<p>$ pip install k8sAI<p>$ k8sAI chat\nOr to fix an issue:\n$ k8sAI fix -p=&quot;take a look at the failing pod in the test namespace&quot;<p>Any and all feedback is appreciated. Looking forward to hearing what you all have to say!<p>Cheers!",
"time": 1714662688,
"title": "Show HN: K8sAI – open-source GPT CLI tool for Kubernetes",
"type": "story",
"url": "https://github.com/wilson090/k8sAI"
}
{
"author": "parity-ai",
"date": null,
"description": "k8sAI is a RAG-enabled GPT for working with k8s. Contribute to parity-ai/k8sAI development by creating an account on GitHub.",
"image": "https://opengraph.githubassets.com/642ac015bb77e404b53510118487235aa8e994ced03bac5131bf67e7983f5c2a/parity-ai/k8sAI",
"logo": "https://logo.clearbit.com/github.com",
"publisher": "GitHub",
"title": "GitHub - parity-ai/k8sAI: k8sAI is a RAG-enabled GPT for working with k8s",
"url": "https://github.com/parity-ai/k8sAI"
}
{
"url": "https://github.com/parity-ai/k8sAI",
"title": "GitHub - parity-ai/k8sAI: k8sAI is a RAG-enabled GPT for working with k8s",
"description": "k8sAI k8sAI is a RAG-enabled GPT that uses a vector store with the embeddings of the Kubernetes documentation. It can answer general questions about Kubernetes, explain output of provided kubectl commands,...",
"links": [
"https://github.com/parity-ai/k8sAI",
"https://github.com/wilson090/k8sAI"
],
"image": "https://opengraph.githubassets.com/642ac015bb77e404b53510118487235aa8e994ced03bac5131bf67e7983f5c2a/parity-ai/k8sAI",
"content": "<div><article><p></p><h2>k8sAI</h2><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#k8sai\"></a><p></p>\n<p>k8sAI is a RAG-enabled GPT that uses a vector store with the embeddings of the <a target=\"_blank\" href=\"https://kubernetes.io/docs/\">Kubernetes documentation</a>.\nIt can answer general questions about Kubernetes, explain output of provided kubectl commands, and suggested commands for you to then easily execute.\nGiven an issue, it can also use kubectl commands to understand the issue and suggest a fix.</p>\n<p>\n <a target=\"_blank\" href=\"https://private-user-images.githubusercontent.com/30668639/327277118-c7bf21a9-2912-4dfb-a6d1-c8e2da370c5f.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjQ5MjQsIm5iZiI6MTcyNTc2NDYyNCwicGF0aCI6Ii8zMDY2ODYzOS8zMjcyNzcxMTgtYzdiZjIxYTktMjkxMi00ZGZiLWE2ZDEtYzhlMmRhMzcwYzVmLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDAzMDM0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM2NzEyYTY2YjZmN2RmNTE4MWJhOTI3MjJlY2VmMzI5ZjkyZGMyMzRiMjhhNmRmYzE0YzdjMTcyNmVmYjU0MmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Fid9NZY8VErvETKTfbgr312WMK02dXrYywCbsjDMcdg\"><img src=\"https://private-user-images.githubusercontent.com/30668639/327277118-c7bf21a9-2912-4dfb-a6d1-c8e2da370c5f.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NjQ5MjQsIm5iZiI6MTcyNTc2NDYyNCwicGF0aCI6Ii8zMDY2ODYzOS8zMjcyNzcxMTgtYzdiZjIxYTktMjkxMi00ZGZiLWE2ZDEtYzhlMmRhMzcwYzVmLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDAzMDM0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM2NzEyYTY2YjZmN2RmNTE4MWJhOTI3MjJlY2VmMzI5ZjkyZGMyMzRiMjhhNmRmYzE0YzdjMTcyNmVmYjU0MmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Fid9NZY8VErvETKTfbgr312WMK02dXrYywCbsjDMcdg\" /></a>\n</p>\n<p>k8sAI has a few tools at its disposal that it can call to answer your questions and fix issues:</p>\n<ul>\n<li><code>Execute_Kubectl_CMD_Tool</code> - k8sAI can use this to execute kubectl read commands to gather more information about your cluster</li>\n<li><code>Suggest_Kubectl_CMD_Tool</code> - k8sAI uses this to suggest a kubectl command to you that you can then edit and execute</li>\n<li><code>k8s_search</code> - This tool is used by k8sAI to search k8s documentation to provide informed solutions</li>\n</ul>\n<p></p><h3>Note:</h3><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#note\"></a><p></p>\n<p>This tool sends data to OpenAI's servers. Please review the OpenAI API terms of use before using this tool.n\nThis tool also executes <code>kubectl</code> commands. They are filtered to be read-only commands, but <strong>you provide explicit approval via (y/n) before every command executes</strong>.</p>\n<p></p><h2>Installation</h2><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#installation\"></a><p></p>\n<p>Use the package manager <a target=\"_blank\" href=\"https://pip.pypa.io/en/stable/\">pip</a> to install k8sAI.</p>\n<p></p><h3>Configuration</h3><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#configuration\"></a><p></p>\n<p>Before using k8sAI, ensure your OpenAI API key is set as an environment variable (<code>OPENAI_API_KEY</code>).</p>\n<p></p><h2>Usage</h2><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#usage\"></a><p></p>\n<p></p><h3>Chat</h3><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#chat\"></a><p></p>\n<p>To start a conversation with k8sAI:</p>\n<p>Options:</p>\n<ul>\n<li>-p, --prompt Provide an initial prompt to start the conversation (optional)</li>\n<li>-t, --terminal Conversation will end after one response (optional)</li>\n<li>--disable-execution Disable execution of kubectl commands (optional)</li>\n</ul>\n<p></p><h3>Explain</h3><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#explain\"></a><p></p>\n<p>To have k8sAI explain the output of a Kubernetes command:</p>\n<div><pre>k8sAI explain --cmd=<span><span>'</span>kubectl [command]<span>'</span></span> [OPTIONS]</pre></div>\n<p>Options:</p>\n<ul>\n<li>-p, --prompt Provide an additional prompt to go along with the command output (optional)</li>\n<li>-t, --terminal Conversation will end after one response (optional)</li>\n<li>--disable-execution Disable execution of kubectl commands (optional)</li>\n</ul>\n<p>Note: Only <code>kubectl</code> commands are valid for explanation.</p>\n<p></p><h3>Fix</h3><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#fix\"></a><p></p>\n<p>To request k8sAI to suggest a fix based on a provided description of the problem:</p>\n<p>If no prompt is provided, k8sAI will attempt to discover the problem itself (under development)</p>\n<p>Options:</p>\n<ul>\n<li>-p, --prompt A prompt describing the problem to analyze (optional)</li>\n<li>-t, --terminal Conversation will end after one response (optional)</li>\n<li>--disable-execution Disable execution of kubectl commands (optional)</li>\n</ul>\n<p>Note: --disable-execution with signficantly reduce k8sAI's ability to discover a problem.</p>\n<p></p><h3>Common Commands</h3><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#common-commands\"></a><p></p>\n<div><pre><span><span>#</span> Start a chat session with k8sAI</span>\nk8sAI chat\n<span><span>#</span> Explain the output a specific kubectl command, end chat after first response</span>\nk8sAI explain --cmd=<span><span>'</span>kubectl get pods<span>'</span></span> -t\n<span><span>#</span> Suggest a fix for a described problem</span>\nk8sAI fix --prompt=<span><span>'</span>Pods in `default` namespace are crashing frequently<span>'</span></span></pre></div>\n<p></p><h2>Contributing</h2><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#contributing\"></a><p></p>\n<p>Pull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.</p>\n<p></p><h2>License</h2><a target=\"_blank\" href=\"https://github.com/parity-ai/k8sAI#license\"></a><p></p>\n<p>This code is distributed under the AGPL v3 licensce.</p>\n</article></div>",
"author": "",
"favicon": "https://github.githubassets.com/favicons/favicon.svg",
"source": "github.com",
"published": "",
"ttr": 88,
"type": "object"
}