Skip to main content
Clanker’s k8s ask mode enables you to interact with your Kubernetes cluster using natural language questions.

Overview

Ask mode uses AI to:
  1. Analyze your question
  2. Determine what kubectl operations are needed
  3. Execute those operations against your cluster
  4. Provide a comprehensive markdown-formatted response
Conversation history is maintained per cluster, enabling follow-up questions and context-aware responses.

Basic usage

Ask questions about your cluster in plain English:
# Basic queries
clanker k8s ask "how many pods are running"
clanker k8s ask "show me all deployments"
clanker k8s ask "list services in default namespace"

# Resource usage
clanker k8s ask "which pods are using the most memory"
clanker k8s ask "show me node CPU usage"
clanker k8s ask "what's the cluster utilization"

# Troubleshooting
clanker k8s ask "why is my nginx pod failing"
clanker k8s ask "show me error logs for the api pod"
clanker k8s ask "tell me the health of my cluster"

Cluster targeting

EKS clusters

Query specific EKS clusters:
# Use cluster name and AWS profile
clanker k8s ask --cluster my-cluster --profile myaws "how many nodes"

# Works with current kubeconfig context
clanker k8s ask "show me all pods"

GKE clusters

Query GKE clusters:
# Specify GCP project and cluster
clanker k8s ask \
  --gcp \
  --gcp-project my-project \
  --cluster my-gke-cluster \
  "show me all pods"

# Use current gcloud config
clanker k8s ask --gcp "list namespaces"

Using kubeconfig

Query using existing kubeconfig:
# Use specific context
clanker k8s ask --context staging "show deployments"

# Use custom kubeconfig file
clanker k8s ask --kubeconfig ~/.kube/custom-config "get pods"

Query examples

Cluster information

clanker k8s ask "how many pods are running"
clanker k8s ask "what version of kubernetes"
clanker k8s ask "show me all namespaces"

Resource usage and monitoring

clanker k8s ask "which pods are using the most memory"
clanker k8s ask "show memory usage by namespace"
clanker k8s ask "is any pod using more than 1GB"

Troubleshooting

clanker k8s ask "why is my nginx pod crashing"
clanker k8s ask "show me error logs for api-server"
clanker k8s ask "which pods are in pending state"

Advanced features

Namespace filtering

Query specific namespaces:
# Default namespace
clanker k8s ask -n production "show all pods"

# All namespaces
clanker k8s ask "list pods in all namespaces"

Multi-step queries

Ask complex questions that require multiple operations:
clanker k8s ask "find the pod using the most memory and show its logs"
clanker k8s ask "tell me which deployment has failing pods and why"
clanker k8s ask "compare CPU usage between production and staging namespaces"

Follow-up questions

Maintained conversation context enables follow-ups:
# First question
clanker k8s ask "show me all pods in default namespace"

# Follow-up (remembers we're talking about default namespace)
clanker k8s ask "which one is using the most memory"

# Another follow-up
clanker k8s ask "show me its logs"

Configuration

AI profile

Use specific AI configuration:
clanker k8s ask --ai-profile production "analyze cluster"

Debug mode

View what kubectl commands are being executed:
clanker k8s ask --debug "show all pods"
Example debug output:
[k8s-ask] Analyzing question: "show all pods"
[k8s-ask] LLM determined operations: [{"operation":"list_pods","parameters":{"all_namespaces":true}}]
[k8s-ask] Executing: kubectl get pods -A -o wide
[k8s-ask] Got 47 pods across 6 namespaces
[k8s-ask] Generating response...

Implementation details

Ask mode is implemented in cmd/k8s.go:202:
cmd/k8s.go:202
var k8sAskCmd = &cobra.Command{
	Use:   "ask [question]",
	Short: "Ask natural language questions about your Kubernetes cluster",
	Long: `Ask natural language questions about your Kubernetes cluster using AI.

The AI will analyze your question, determine what kubectl operations are needed,
execute them, and provide a comprehensive markdown-formatted response.

Conversation history is maintained per cluster for follow-up questions.

Examples:
  clanker k8s ask "how many pods are running"
  clanker k8s ask --cluster test-cluster "show me all deployments"
  clanker k8s ask "which pods are using the most memory"
  clanker k8s ask "why is my pod crashing"`,
	Args: cobra.ExactArgs(1),
	RunE: runK8sAsk,
}
The AI decision flow is handled by the LLM integration:
internal/k8s/llm.go:14
type K8sOperation struct {
	Operation  string                 `json:"operation"`
	Reason     string                 `json:"reason"`
	Parameters map[string]interface{} `json:"parameters"`
}

type K8sAnalysis struct {
	Operations []K8sOperation `json:"operations"`
	Analysis   string         `json:"analysis"`
}
Operations are executed in parallel for performance:
internal/k8s/llm.go:34
func (c *Client) ExecuteOperations(ctx context.Context, operations []K8sOperation) (string, error) {
	resultChan := make(chan K8sOperationResult, len(operations))
	var wg sync.WaitGroup

	for i, op := range operations {
		wg.Add(1)
		go func(index int, operation K8sOperation) {
			defer wg.Done()
			result, err := c.executeK8sOperation(ctx, operation)
			resultChan <- K8sOperationResult{
				Operation: operation.Operation,
				Result:    result,
				Error:     err,
				Index:     index,
			}
		}(i, op)
	}

	wg.Wait()
	return k8sResults.String(), nil
}

Supported operations

The AI can execute these kubectl operations:
  • get_cluster_info - Get cluster details
  • get_nodes - List all nodes
  • get_node_details - Describe specific node
  • get_namespaces - List namespaces
  • get_cluster_version - Get Kubernetes version
  • list_pods - List pods
  • get_pod_details - Describe specific pod
  • list_deployments - List deployments
  • list_statefulsets - List statefulsets
  • list_daemonsets - List daemonsets
  • list_jobs - List jobs
  • list_cronjobs - List cronjobs
  • list_services - List services
  • get_service_details - Describe service
  • list_ingresses - List ingresses
  • list_endpoints - List endpoints
  • list_network_policies - List network policies
  • list_pvs - List persistent volumes
  • list_pvcs - List persistent volume claims
  • list_storage_classes - List storage classes
  • list_configmaps - List ConfigMaps
  • list_secrets - List secrets
  • get_pod_logs - Get pod logs
  • get_events - Get cluster events
  • get_warning_events - Get warning events
  • get_node_metrics - Get node resource usage
  • get_pod_metrics - Get pod resource usage
  • get_top_nodes - Top nodes by usage
  • get_top_pods - Top pods by usage
  • describe_resource - Describe any resource
  • check_pod_errors - Find error pods
  • get_unhealthy_pods - Find unhealthy pods
  • get_pending_pods - Find pending pods

Tips and best practices

Be specific: Instead of “show pods”, try “show failing pods in production namespace”.
Use context: Follow-up questions work better when they reference previous responses.
Include metrics: Questions like “which pods use the most memory” automatically fetch metrics.
Ask mode executes read-only kubectl commands. It cannot modify your cluster.

Next steps

Monitoring

Learn about detailed cluster monitoring

Cluster management

Manage cluster lifecycle

Build docs developers (and LLMs) love