# kubectl-ai — AI-Powered Kubernetes Assistant by Google > An official Google Cloud tool that brings AI to the kubectl command line, translating natural language into Kubernetes operations for faster cluster management and troubleshooting. ## Install Save in your project root: # kubectl-ai — AI-Powered Kubernetes Assistant by Google ## Quick Use ```bash # Install as a kubectl plugin gcloud components install kubectl-ai # Or install via Go go install github.com/GoogleCloudPlatform/kubectl-ai@latest # Run with natural language kubectl ai "show all pods that are not running in the default namespace" ``` ## Introduction kubectl-ai is an open-source kubectl plugin developed by Google Cloud Platform that lets you interact with Kubernetes clusters using natural language. Instead of memorizing complex kubectl commands, flags, and YAML syntax, you describe what you want in plain English and kubectl-ai translates it into the correct Kubernetes operations, with safety confirmations before any changes are applied. ## What kubectl-ai Does - Translates natural language queries into kubectl commands and executes them - Generates Kubernetes YAML manifests from descriptive prompts - Provides cluster troubleshooting assistance by analyzing resource states - Shows the generated command before execution so you can review and approve - Supports both read-only queries and mutating operations with confirmation prompts ## Architecture Overview kubectl-ai works as a kubectl plugin that intercepts natural language input, sends it to a configured LLM along with cluster context (namespace, available resources, current state), and parses the response into executable kubectl commands or YAML manifests. The plugin uses the Kubernetes client-go library for cluster interaction and maintains conversation context for multi-turn troubleshooting sessions. Safety guards prevent destructive operations without explicit user confirmation. ## Self-Hosting & Configuration - Install via gcloud components or build from source with Go 1.21+ - Supports Gemini, OpenAI, and Anthropic as LLM backends - Uses your existing kubeconfig for cluster authentication and context - Configure the default LLM provider and model via environment variables or config file - Works with any standard Kubernetes cluster including GKE, EKS, AKS, and self-hosted ## Key Features - Natural language to kubectl command translation with preview before execution - YAML manifest generation from descriptive requirements - Cluster state awareness for contextual troubleshooting and diagnostics - Safety-first design requiring confirmation for any mutating operations - Multi-turn conversation support for iterative debugging sessions ## Comparison with Similar Tools - **K8sGPT** — Focuses on diagnostics and scanning; kubectl-ai covers the full range of kubectl operations including resource creation - **k9s** — Terminal UI for cluster browsing; kubectl-ai adds natural language interaction and command generation - **Lens** — Desktop GUI for Kubernetes; kubectl-ai stays in the terminal with AI-augmented CLI workflows - **Headlamp** — Web UI for clusters; kubectl-ai provides AI-assisted command-line operations without a browser ## FAQ **Q: Does kubectl-ai send cluster data to external APIs?** A: Cluster context like resource names and states may be sent to the configured LLM. Use a local model for sensitive environments. **Q: Can kubectl-ai modify production clusters?** A: Yes, but all mutating operations require explicit user confirmation before execution. **Q: Which Kubernetes versions are supported?** A: kubectl-ai works with any cluster version supported by your installed kubectl binary. **Q: Does it work with custom resource definitions (CRDs)?** A: Yes, kubectl-ai can discover and interact with CRDs installed in your cluster. ## Sources - https://github.com/GoogleCloudPlatform/kubectl-ai - https://cloud.google.com/kubernetes-engine/docs --- Source: https://tokrepo.com/en/workflows/asset-27c0f4ab Author: AI Open Source