← all repositories
sozercan/kubectl-ai

kubectl-ai: ChatGPT for your Kubernetes YAML

A kubectl plugin that lets you describe what you want in plain English and generates the manifest for you.

kubectl-ai
Velocity · 7d
+1.0
★ / day
Trend
steady
star history

What it does

kubectl-ai is a kubectl plugin that turns natural language prompts into Kubernetes manifests. Type kubectl ai "create an nginx deployment with 3 replicas" and it generates the YAML, shows it to you, and optionally applies it after confirmation. It supports OpenAI, Azure OpenAI, and local OpenAI-compatible endpoints like LocalAI or the author’s own AIKit project.

The interesting bit

The --use-k8s-api flag is the quietly clever part: it feeds your cluster’s actual OpenAPI spec (including CRDs) to the LLM via function calling, so generated manifests match your specific cluster’s schema rather than generic training data. The author also notes the plugin “does not know the current state of the cluster (yet?)”, which is an honest admission of a real limitation.

Key highlights

  • Interactive confirmation prompt with reprompting to refine requests without retyping
  • Pipe-friendly: cat foo.yaml | kubectl ai "change replicas to 5" --raw | kubectl apply -f -
  • Works with local LLMs via Docker (no GPU required with AIKit’s Llama 3.1 image)
  • Azure deployment name mangling handled automatically (gpt-3.5-turbogpt-35-turbo)
  • Can pipe raw output to editors like code - or vim - for manual review

Caveats

  • Always generates full manifests; doesn’t diff against existing cluster state
  • --use-k8s-api requires function-capable models (0613+) and burns more API calls
  • Default model is gpt-3.5-turbo-0301, which is fairly dated

Verdict

Worth a look if you spend too much time cargo-culting YAML from Stack Overflow or maintaining a personal snippets folder. Skip it if you already have a solid templating setup or don’t trust LLMs near production clusters.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.