{"id":25725000,"url":"https://github.com/googlecloudplatform/kubectl-ai","last_synced_at":"2025-05-14T11:10:35.288Z","repository":{"id":278963071,"uuid":"919615603","full_name":"GoogleCloudPlatform/kubectl-ai","owner":"GoogleCloudPlatform","description":"AI powered Kubernetes Assistant","archived":false,"fork":false,"pushed_at":"2025-05-07T02:16:17.000Z","size":3546,"stargazers_count":2204,"open_issues_count":20,"forks_count":151,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-07T06:38:33.284Z","etag":null,"topics":["ai","assistant","cli","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleCloudPlatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-20T18:07:16.000Z","updated_at":"2025-05-07T06:38:19.000Z","dependencies_parsed_at":"2025-02-22T20:30:40.495Z","dependency_job_id":"464b07ef-f074-4bf2-aa79-9aeb396cd8dc","html_url":"https://github.com/GoogleCloudPlatform/kubectl-ai","commit_stats":null,"previous_names":["googlecloudplatform/kubectl-ai"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fkubectl-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fkubectl-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fkubectl-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fkubectl-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleCloudPlatform","download_url":"https://codeload.github.com/GoogleCloudPlatform/kubectl-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129489,"owners_count":22019628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","assistant","cli","kubernetes"],"created_at":"2025-02-25T22:17:32.041Z","updated_at":"2025-05-14T11:10:35.262Z","avatar_url":"https://github.com/GoogleCloudPlatform.png","language":"Go","readme":"# kubectl-ai\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/GoogleCloudPlatform/kubectl-ai)](https://goreportcard.com/report/github.com/GoogleCloudPlatform/kubectl-ai)\n![GitHub License](https://img.shields.io/github/license/GoogleCloudPlatform/kubectl-ai)\n[![GitHub stars](https://img.shields.io/github/stars/GoogleCloudPlatform/kubectl-ai.svg)](https://github.com/GoogleCloudPlatform/kubectl-ai/stargazers)\n\n`kubectl-ai` acts as an intelligent interface, translating user intent into\nprecise Kubernetes operations, making Kubernetes management more accessible and\nefficient.\n\n![kubectl-ai demo GIF using: kubectl-ai \"how's nginx app doing in my cluster\"](./.github/kubectl-ai.gif)\n\n## Quick Start\n\nFirst, ensure that kubectl is installed and configured.\n\n### Installation\n\n#### Quick Install (Linux \u0026 MacOS only)\n\n```shell\ncurl -sSL https://raw.githubusercontent.com/GoogleCloudPlatform/kubectl-ai/main/install.sh | bash\n```\n\n#### Manual Installation (Linux, MacOS and Windows)\n\n1. Download the latest release from the [releases page](https://github.com/GoogleCloudPlatform/kubectl-ai/releases/latest) for your target machine.\n\n2. Untar the release, make the binary executable and move it to a directory in your $PATH (as shown below).\n\n```shell\ntar -zxvf kubectl-ai_Darwin_arm64.tar.gz\nchmod a+x kubectl-ai\nsudo mv kubectl-ai /usr/local/bin/\n```\n\n#### Install with Krew (Linux/macOS/Windows)\nFirst of all, you need to have krew insatlled, refer to [krew document](https://krew.sigs.k8s.io/docs/user-guide/setup/install/) for more details\nThen you can install with krew\n```shell\nkubectl krew install ai\n```\nNow you can invoke `kubectl-ai` as a kubectl plugin like this: `kubectl ai`.\n\n### Usage\n\n#### Using Gemini (Default)\n\nSet your Gemini API key as an environment variable. If you don't have a key, get one from [Google AI Studio](https://aistudio.google.com).\n\n```bash\nexport GEMINI_API_KEY=your_api_key_here\nkubectl-ai\n\n# Use different gemini model\nkubectl-ai --model gemini-2.5-pro-exp-03-25\n\n# Use 2.5 flash (faster) model\nkubectl-ai --quiet --model gemini-2.5-flash-preview-04-17 \"check logs for nginx app in hello namespace\"\n```\n\n#### Using AI models running locally (ollama or llama.cpp)\n\nYou can use `kubectl-ai` with AI models running locally. `kubectl-ai` supports [ollama](https://ollama.com/) and [llama.cpp](https://github.com/ggml-org/llama.cpp) to use the AI models running locally.\n\nAdditionally, the [`modelserving`](modelserving/) directory provides tools and instructions for deploying your own `llama.cpp`-based LLM serving endpoints locally or on a Kubernetes cluster. This allows you to host models like Gemma directly in your environment.\n\nAn example of using Google's `gemma3` model with `ollama`:\n\n```shell\n# assuming ollama is already running and you have pulled one of the gemma models\n# ollama pull gemma3:12b-it-qat\n\n# if your ollama server is at remote, use OLLAMA_HOST variable to specify the host\n# export OLLAMA_HOST=http://192.168.1.3:11434/\n\n# enable-tool-use-shim because models require special prompting to enable tool calling\nkubectl-ai --llm-provider ollama --model gemma3:12b-it-qat --enable-tool-use-shim\n\n# you can use `models` command to discover the locally available models\n\u003e\u003e models\n```\n\n#### Using Grok\n\nYou can use X.AI's Grok model by setting your X.AI API key:\n\n```bash\nexport GROK_API_KEY=your_xai_api_key_here\nkubectl-ai --llm-provider=grok --model=grok-3-beta\n```\n\n#### Using Azure OpenAI\n\nYou can also use Azure OpenAI deployment by setting your OpenAI API key and specifying the provider:\n\n```bash\nexport AZURE_OPENAI_API_KEY=your_azure_openai_api_key_here\nexport AZURE_OPENAI_ENDPOINT=https://your_azure_openai_endpoint_here\nkubectl-ai --llm-provider=azopenai --model=your_azure_openai_deployment_name_here\n# or\naz login\nkubectl-ai --llm-provider=openai://your_azure_openai_endpoint_here --model=your_azure_openai_deployment_name_here\n```\n\n#### Using OpenAI\n\nYou can also use OpenAI models by setting your OpenAI API key and specifying the provider:\n\n```bash\nexport OPENAI_API_KEY=your_openai_api_key_here\nkubectl-ai --llm-provider=openai --model=gpt-4.1\n```\n\n#### Using OpenAI Compatible API\nFor example, you can use aliyun qwen-xxx models as follows\n```bash\nexport OPENAI_API_KEY=your_openai_api_key_here\nexport OPENAI_ENDPOINT=https://dashscope.aliyuncs.com/compatible-mode/v1\nkubectl-ai --llm-provider=openai --model=qwen-plus\n```\n\n* Note: `kubectl-ai` supports AI models from `gemini`, `vertexai`, `azopenai`, `openai`, `grok` and local LLM providers such as `ollama` and `llama.cpp`.\n\nRun interactively:\n\n```shell\nkubectl-ai\n```\n\nThe interactive mode allows you to have a chat with `kubectl-ai`, asking multiple questions in sequence while maintaining context from previous interactions. Simply type your queries and press Enter to receive responses. To exit the interactive shell, type `exit` or press Ctrl+C.\n\nOr, run with a task as input:\n\n```shell\nkubectl-ai --quiet \"fetch logs for nginx app in hello namespace\"\n```\n\nCombine it with other unix commands:\n\n```shell\nkubectl-ai \u003c query.txt\n# OR\necho \"list pods in the default namespace\" | kubectl-ai\n```\n\nYou can even combine a positional argument with stdin input. The positional argument will be used as a prefix to the stdin content:\n\n```shell\ncat error.log | kubectl-ai \"explain the error\"\n```\n\n## Extras\n\nYou can use the following special keywords for specific actions:\n\n* `model`: Display the currently selected model.\n* `models`: List all available models.\n* `version`: Display the `kubectl-ai` version.\n* `reset`: Clear the conversational context.\n* `clear`: Clear the terminal screen.\n* `exit` or `quit`: Terminate the interactive shell (Ctrl+C also works).\n\n### Invoking as kubectl plugin\n\nUse it via the `kubectl` plug interface like this: `kubectl ai`.  kubectl will find `kubectl-ai` as long as it's in your PATH.  For more information about plugins please see: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/\n\n\n### Examples\n\n```bash\n# Get information about pods in the default namespace\nkubectl-ai --quiet \"show me all pods in the default namespace\"\n\n# Create a new deployment\nkubectl-ai --quiet \"create a deployment named nginx with 3 replicas using the nginx:latest image\"\n\n# Troubleshoot issues\nkubectl-ai --quiet \"double the capacity for the nginx app\"\n\n# Using Azure OpenAI instead of Gemini\nkubectl-ai --llm-provider=azopenai --model=your_azure_openai_deployment_name_here --quiet \"scale the nginx deployment to 5 replicas\"\n\n# Using OpenAI instead of Gemini\nkubectl-ai --llm-provider=openai --model=gpt-4.1 --quiet \"scale the nginx deployment to 5 replicas\"\n```\n\nThe `kubectl-ai` will process your query, execute the appropriate kubectl commands, and provide you with the results and explanations.\n\n## MCP server\n\nYou can also use `kubectl-ai` as a MCP server that exposes `kubectl` as one of the tools to interact with locally configured k8s environment. See [mcp docs](./docs/mcp.md) for more details.\n\n## k8s-bench\n\nkubectl-ai project includes [k8s-bench](./k8s-bench/README.md) - a benchmark to evaluate performance of different LLM models on kubernetes related tasks. Here is a summary from our last run:\n\n| Model | Success | Fail |\n|-------|---------|------|\n| gemini-2.5-flash-preview-04-17 | 10 | 0 |\n| gemini-2.5-pro-preview-03-25 | 10 | 0 |\n| gemma-3-27b-it | 8 | 2 |\n| **Total** | 28 | 2 |\n\nSee [full report](./k8s-bench.md) for more details.\n\n## Start Contributing\n\nWe welcome contributions to `kubectl-ai` from the community. Take a look at our\n[contribution guide](contributing.md) to get started.\n\n---\n\n*Note: This is not an officially supported Google product. This project is not\neligible for the [Google Open Source Software Vulnerability Rewards\nProgram](https://bughunters.google.com/open-source-security).*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fkubectl-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglecloudplatform%2Fkubectl-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fkubectl-ai/lists"}