kubectl-ai

(★ 7,549)

AI powered Kubernetes Assistant

File Explorer

  • .gitignore
  • .goreleaser.yaml
  • .krew.yaml
  • CONTAINER.md
  • contributing.md
  • go.mod
  • go.sum
  • go.work
  • go.work.sum
  • install.sh
  • kubectl-ai.png
  • LICENSE
  • makefile
  • README.md

# Installation Guide

go
Prerequisites

Setup Steps

curl -sSL https://raw.githubusercontent.com/GoogleCloudPlatform/kubectl-ai/main/install.sh | bash

Run the quick install script for Linux and macOS environments.

kubectl krew install ai

Install as a kubectl plugin via krew.

export GEMINI_API_KEY=your_api_key_here

Set the API key environment variable for the AI model to use.

kubectl-ai

Run kubectl-ai to start an interactive session.

Key Commands

kubectl-ai

Run kubectl-ai in interactive mode to query cluster state using natural language.

kubectl ai

Run kubectl-ai as a kubectl plugin.

kubectl-ai --quiet "fetch logs for nginx app in hello namespace"

Execute a specific task in non-interactive mode and output the result.

Depending on the chosen LLM provider, setting environment variables such as GEMINI_API_KEY, OPENAI_API_KEY, or GROK_API_KEY is required.

# Use via CDN

jsDelivr

jsDelivr serves any public GitHub repository as a CDN with zero setup. Pick a version and a file to get a ready-to-paste link and snippet.

Command Glossary

Commands referenced in this DOCs, explained below.

🔍

aws sso

View Details ▼

Manage access to AWS resources using Single Sign-On (SSO) credentials.

aws sso login

Start SSO session and refresh access tokens. Requires setup using `aws configure sso`:

aws sso logout

End SSO session and clear cached access tokens:

aws sso list-accounts

List all AWS accounts accessible to the user:

🔍

az login

View Details ▼

Log in to Azure.
Part of `azure-cli` (also known as `az`).

az login

Log in interactively:

az login --service-principal {{[-u|--username]}} {{http://azure-cli-service-principal}} {{[-p|--password]}} {{secret}} {{[-t|--tenant]}} {{someone.onmicrosoft.com}}

Log in with a service principal using a client secret:

az login --service-principal {{[-u|--username]}} {{http://azure-cli-service-principal}} {{[-p|--password]}} {{path/to/cert.pem}} {{[-t|--tenant]}} {{someone.onmicrosoft.com}}

Log in with a service principal using a client certificate:

🔍

docker build

View Details ▼

Build an image from a Dockerfile.

docker build .

Build a Docker image using the Dockerfile in the current directory:

docker build {{github.com/creack/docker-firefox}}

Build a Docker image from a Dockerfile at a specified URL:

docker build {{[-t|--tag]}} {{name:tag}} .

Build a Docker image and tag it:

🔍

docker run

View Details ▼

This command is an alias of `docker container run`.

tldr docker container run

View documentation for the original command:

🔍

gcloud auth

View Details ▼

Grant and revoke authorization to `gcloud` and manage credentials.
See also: `gcloud`.

gcloud auth login

Authorize Google Cloud access for the `gcloud` CLI with Google Cloud user credentials and set the current account as active:

gcloud auth activate-service-account

Authorize Google Cloud access similar to `gcloud auth login` but with service account credentials:

gcloud auth application-default

Manage Application Default Credentials (ADC) for Cloud Client Libraries:

🔍

gcloud container

View Details ▼

Manage containerized applications on Kubernetes and clusters.
See also: `gcloud`.

gcloud auth configure-docker

Register `gcloud` as a Docker credential helper:

gcloud container clusters create {{cluster_name}}

Create a cluster to run GKE containers:

gcloud container clusters list

List clusters for running GKE containers:

🔍

gemini

View Details ▼

Launch an interactive prompt with Gemini AI.

gemini

Start a REPL session to chat interactively:

{{echo "Summarize the history of Rome"}} | gemini {{[-p|--prompt]}} -

Send the output of another command to Gemini and exit immediately:

gemini {{[-m|--model]}} {{model_name}}

Use a specific model (default: auto-gemini-3):

🔍

git clone

View Details ▼

Clone an existing repository.

git clone {{remote_repository_location}} {{path/to/directory}}

Clone an existing repository into a new directory (the default directory is the repository name):

git clone --recursive {{remote_repository_location}}

Clone an existing repository and its submodules:

git clone {{[-n|--no-checkout]}} {{remote_repository_location}}

Clone only the `.git` directory of an existing repository:

🔍

kubectl krew

View Details ▼

Plugin manager for `kubectl`.
See also: `kubectl-plugin`.

kubectl krew search

Search for available plugins:

kubectl krew install {{plugin_name}}

Install a plugin:

kubectl krew list

List installed plugins:

🔍

kubectl

View Details ▼

Run commands against Kubernetes clusters.
Some subcommands such as `run` have their own usage documentation.

kubectl get {{pods|service|deployment|ingress|...}} {{[-o|--output]}} wide

List information about a resource with more details:

kubectl label pods {{name}} unhealthy=true

Update specified pod with the label `unhealthy` and the value `true`:

kubectl get all

List all resources with different types:

🔍

nix-shell

View Details ▼

Start an interactive shell based on a Nix expression.
See also: `nix shell.3`.

nix-shell

Start with nix expression in `shell.nix` or `default.nix` in the current directory:

nix-shell --run "{{command}} {{argument1 argument2 ...}}"

Run shell command in non-interactive shell and exit:

nix-shell {{default.nix}}

Start with expression in `default.nix` in the current directory:

🔍

ollama

View Details ▼

A large language model runner.
For a list of available models, see <https://ollama.com/library>.

ollama serve

Start the daemon required to run other commands:

ollama run {{model}}

Run a model and chat with it (will automatically download the model if it's not downloaded):

ollama run {{model}} --think=false "{{prompt}}"

Run a model with a single prompt and thinking turned off:

🔍

openai

View Details ▼

CLI tool providing access to the OpenAI API.

openai api models.list

List models:

openai api completions.create --model {{ada}} --prompt "{{Hello world}}"

Create a completion:

openai api chat_completions.create --model {{gpt-3.5-turbo}} --message {{user "Hello world"}}

Create a chat completion:

🔍

tar

View Details ▼

Archiving utility.
Often combined with a compression method, such as `gzip` or `bzip2`.

tar cf {{path/to/target.tar}} {{path/to/file1 path/to/file2 ...}}

[c]reate an archive and write it to a [f]ile:

tar czf {{path/to/target.tar.gz}} {{path/to/file1 path/to/file2 ...}}

[c]reate a g[z]ipped archive and write it to a [f]ile:

tar czf {{path/to/target.tar.gz}} {{[-C|--directory]}} {{path/to/directory}} .

[c]reate a g[z]ipped (compressed) archive from a directory using relative paths:

🔍

gemma3

View Details ▼

The examples for this command have been moved together with `inference-snap`.

tldr inference-snap

View documentation for `inference-snap`:

# Project Badges

  • Go Report Card Go Report Card Visit
  • GitHub License GitHub License
  • Ask DeepWiki Ask DeepWiki Visit
  • GitHub stars GitHub stars Visit
// repository documentation