# kubectl-ai

> Terminal assistant that turns natural-language requests into kubectl and bash operations using Gemini, OpenAI, Bedrock, Ollama and other LLM providers.

Stars: 7.6k · Language: Go · License: Apache-2.0 · Categories: AI

- Repository: https://github.com/GoogleCloudPlatform/kubectl-ai
- Page: https://www.trmn.sh/tools/kubectl-ai

## Install

- Quick install script (Linux & macOS): `curl -sSL https://raw.githubusercontent.com/GoogleCloudPlatform/kubectl-ai/main/install.sh | bash`
- Krew: `kubectl krew install ai`
- Nix: `nix-shell -p kubectl-ai`

## Overview

kubectl-ai is a command-line assistant for Kubernetes that takes natural-language requests, such as "check logs for nginx app in hello namespace", and uses an LLM to suggest and run the matching Kubernetes operations. Its built-in tools are kubectl and bash. You can add custom tools through a tools.yaml file, which it reads from ~/.config/kubectl-ai/tools.yaml by default, or from a path given with --custom-tools-config.

It runs in an interactive chat mode that keeps context across questions, or in a non-interactive mode with --quiet and a task argument. It also reads stdin, so you can run `cat error.log | kubectl-ai "explain the error"`, where the positional argument becomes a prefix to the piped content. Sessions can be saved and resumed with --new-session, --list-sessions, --resume-session and --delete-session. Settings can be given as command-line flags, in ~/.config/kubectl-ai/config.yaml, or as environment variables, and flags take precedence over the config file.

It supports several model providers: gemini (the default), vertexai, azopenai, openai, grok and bedrock. It also supports local models through ollama and llama.cpp, and OpenAI-compatible endpoints such as Alibaba's Qwen. For models that need special prompting for tool calling, there is an --enable-tool-use-shim flag. The README also documents an MCP server mode, an MCP client mode, a web UI option (uiType: web), and a Docker image that can be used against a GKE cluster. The tool is aimed at developers, platform engineers and SREs who work with Kubernetes clusters from the terminal.

### Installation

```bash
# via Quick install script (Linux & macOS)
curl -sSL https://raw.githubusercontent.com/GoogleCloudPlatform/kubectl-ai/main/install.sh | bash
```

```bash
# via Krew
kubectl krew install ai
```

```bash
# via Nix
nix-shell -p kubectl-ai
```

![kubectl-ai demo GIF using: kubectl-ai "how's nginx app doing in my cluster"](https://media.trmn.sh/cached/495e606da3510ffbd0c051de66e1352816f0c86942dad85cd3c2e159a285a79e.gif)

## Alternatives

- [Claude Squad](https://www.trmn.sh/tools/claude-squad.md): Terminal UI that runs multiple AI coding agents (Claude Code, Codex, Gemini, Aider) in parallel, each in its own tmux session and git worktree. (Go, 8.7k stars)
- [mods](https://www.trmn.sh/tools/mods.md): CLI tool that adds AI capabilities to command line pipelines by processing stdin through LLMs (Go, 4.5k stars)
- [Crush](https://www.trmn.sh/tools/crush.md): Terminal-based agentic coding assistant from Charm that connects to many LLM providers, uses LSPs for context, and extends via MCP servers. (Go, 28.9k stars)
- [DeepSeek-Reasonix](https://www.trmn.sh/tools/deepseek-reasonix.md): Open-source coding agent shipped as a single Go binary with a TUI, desktop app, and ACP editor integration; DeepSeek preset, any OpenAI-compatible model. (Go, 36.0k stars)
- [Ollama](https://www.trmn.sh/tools/ollama.md): CLI tool for running and managing local large language models with REST API and client library support (Go, 185.1k stars)

---

Canonical: https://www.trmn.sh/tools/kubectl-ai
