Supercharging Kubernetes Debugging: A Guide to K8sGPT + Google Gemini 2.5 Pro
Kubernetes observability is great, but actionable intelligence is better. K8sGPT is a CNCF tool that scans your clusters, diagnoses issues, and uses AI to explain them in plain English.
While OpenAI is the default backend, Google's Gemini models (specifically the newer 1.5 and 2.5 series) offer incredible performance, often with larger context windows and faster inference speeds.
However, setting it up isn't always straightforward due to API versioning and CLI flag nuances. In this guide, we’ll walk through how to integrate the powerful Gemini 2.5 Pro model with K8sGPT, handling common errors like "Model not found" and flag deprecations along the way.
Prerequisites
- A running Kubernetes cluster.
- K8sGPT CLI installed.
- A Google AI Studio API Key.
1. The Clean Slate: Handling Existing Providers
If you have experimented with K8sGPT before, you might hit an error saying Provider with same name already exists. Before adding a new configuration, it is best practice to remove any stale Google backends.
Command:
This ensures you aren't fighting against cached configurations or old API keys.
2. Adding Gemini 2.5 Pro (The Right Way)
This is the most critical step. Many tutorials suggest using gemini-pro, but Google’s API moves fast. Using generic or older model names often results in a 404 Model Not Found error during analysis.
To get the best results, target the specific model version. We will use Gemini 2.5 Pro for its advanced reasoning capabilities.
Command:
Pro Tip: If you prefer not to leave your API key in your shell history, omit the --password flag. K8sGPT will prompt you to enter it securely.3. Setting the Default Provider (Watch the Flags!)
A common point of confusion is the flag used to set the default backend. While the auth add command uses --backend, the auth default command strictly requires --provider.
If you run k8sgpt auth default --backend google, you will get an unknown flag: --backend error.
Correct Command:
To verify that Google is now your default AI provider:
Look for the (default) tag next to Google.
4. Running the Analysis
Now that the backend is configured with a high-performance model, you can scan your cluster. The --explain flag tells K8sGPT to send the error logs to Gemini and return a solution.
Command:
What happens in the background?
- K8sGPT scans your cluster for
CrashLoopBackOff,Pendingpods, or Service failures. - It extracts the relevant error logs (anonymizing sensitive data if configured).
- It sends this context to Gemini 2.5 Pro.
- Gemini analyzes the root cause (e.g., “Readiness probe failed because port 8080 is unreachable”) and suggests a
kubectlfix.