Welcome to a hands-on demonstration of K8sGPT, your AI assistant for Kubernetes diagnostics and remediation. In this lesson, we’ll:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- Authenticate with your AI backend
- Scan and explain cluster issues
- Filter results by namespace and resource type
- Review common NGINX deployment errors and solutions
1. Authenticate Your AI Backend
Before using K8sGPT, add your OpenAI (or Hugging Face) API key:K8sGPT supports multiple backends (e.g., OpenAI and Hugging Face). If you don’t specify, it defaults to OpenAI’s
gpt-3.5-turbo.2. Cluster Analysis Commands
| Command | Description | Example |
|---|---|---|
k8sgpt analyze | Scan all namespaces | — |
k8sgpt analyze --explain --namespace k8sgpt | Explain issues in a specific namespace | — |
k8sgpt analyze --explain --filter=Deployment | Filter output by resource type (e.g., Deployment) | — |
k8sgpt analyze --explain --namespace k8sgpt --output=json | Get machine-readable JSON output | — |
k8sgpt analyze ... --anonymize | Remove sensitive data from output | — |
3. Scan Your Cluster
-
All namespaces
-
Specific namespace
4. Common NGINX Deployment Errors & Fixes
When focusing on thek8sgpt namespace’s NGINX deployment, K8sGPT may report:

4.1 Error: Service has no ready endpoints
Solution:- Check pod status
- Describe the failing pod
- Inspect logs
- Verify readiness probes, then restart
4.2 Error: Back-off pulling image “nginx:5.5”
Solution:- Confirm the tag exists on Docker Hub.
- If missing, update to a valid tag (e.g.,
nginx:latest) in your Deployment YAML. - Apply the updated manifest:
5. Filtering by Resource Type
5.1 Deployments Only
kubectl get pods -n k8sgptkubectl describe pod <pod-name> -n k8sgptkubectl logs <pod-name> -n k8sgpt- Fix image or spec issues, then rollout restart.
5.2 Services Only
kubectl get pods -l app=k8sgpt-ollama -n k8sgpt- Label pods if missing:
- Ensure pods are
RunningandReady.
6. JSON & Anonymized Output
-
JSON output
-
Anonymize sensitive data
When sharing logs or JSON output publicly, use
--anonymize to mask identifiers.