K8sGPT helps identify likely causes of Kubernetes problems by analyzing cluster information and presenting plain-language explanations. Use it as a read-only diagnostic aid: verify its findings against Kubernetes events, logs, and configuration, then make any changes yourself through your normal review process.
What You’ll Need
- A Kubernetes cluster you are authorized to inspect, plus a working
kubectlcontext. - The K8sGPT CLI installed from its official project documentation, and access to a terminal.
- Permission to read the relevant cluster resources. For most diagnosis, avoid granting write access.
- Optionally, a configured AI provider or analyzer. K8sGPT can also run analyzers without sending data to an external AI service.
- A change-control or incident process for approving and applying any repair identified by the analysis.
Step-by-Step
- Confirm you are inspecting the right cluster. Run
kubectl config current-context, then check the cluster and namespace you intend to investigate. If needed, specify a context with--contextand a namespace with-nin later commands. This prevents analysis of the wrong environment. - Check that Kubernetes access is read-only for diagnosis. Confirm your identity and permissions with
kubectl auth can-i get pods -n YOUR_NAMESPACEand similar checks for deployments, events, and other relevant resources. Use an appropriately scoped account. K8sGPT analysis should not need permission to delete, patch, or modify workloads. - Start with built-in analysis. Run
k8sgpt analyze. To focus on a namespace, use the namespace option supported by your installed CLI, commonly--namespace YOUR_NAMESPACE. Checkk8sgpt analyze --helpif flags differ in your release. Review the resource names, reported symptoms, and diagnostic details; treat proposed causes as hypotheses. - Limit the scope when the output is noisy. Use available filters to focus on the resource types connected to the incident. List filters with
k8sgpt filters list, and consultk8sgpt analyze --helpfor the filter syntax supported by your version. A narrow analysis can make it easier to compare findings with a specific pod, deployment, or service. - Inspect the underlying Kubernetes evidence. For each finding, check current state and events, for example with
kubectl describe pod POD -n YOUR_NAMESPACE,kubectl get events -n YOUR_NAMESPACE --sort-by=.lastTimestamp, andkubectl logs POD -n YOUR_NAMESPACE --all-containers. For a restarting container, add--previousto inspect its prior logs. Check workload configuration withkubectl describe deployment DEPLOYMENT -n YOUR_NAMESPACEor review its manifest. - Choose whether to use an AI explanation. K8sGPT can send filtered diagnostic information to a configured provider for explanation. First review the provider and analyzer setup using
k8sgpt auth listand the relevant help or configuration documentation for your release. Do not assume that filtering removes every sensitive value. Inspect what will be shared and follow your organization’s data-handling rules before enabling a provider. - Keep analysis separate from repair. Do not use an automatic fix, remediation, or write-enabled integration as the next step just because K8sGPT suggests it. If your installation exposes such options, leave them disabled during diagnosis. Translate a finding into a proposed change, inspect the exact manifest or command, and have an authorized operator review its impact and rollback plan.
- Test a change in a controlled way. Prefer a reviewed manifest change through your established deployment workflow, and test in a non-production environment when practical. Before applying anything, confirm the target context and namespace and save the current configuration if your process requires it. Avoid unreviewed commands that delete pods, change resource limits, alter access controls, or restart services.
- Verify the result and preserve the evidence. Re-run the relevant read-only K8sGPT analysis and check pod readiness, events, logs, and application behavior. A cleared warning alone does not prove the service is healthy. Record the original finding, evidence, approved change, and outcome so the diagnosis can be reviewed later.
Common Mistakes
- Treating an explanation as a confirmed root cause: AI-generated descriptions can be incomplete or wrong. Confirm them with live resource state, events, logs, and application-specific evidence.
- Running commands against the wrong context: A valid command can still affect the wrong cluster. Check the context before every manual change, especially when switching between test and production.
- Giving the diagnostic tool broad write permissions: Read access is usually enough to investigate. Avoid cluster-admin privileges or write-capable credentials unless a separately reviewed operational task truly requires them.
- Sharing sensitive data without checking: Logs, resource names, annotations, and configuration may contain private details or secrets. Review data handling before using an external provider; do not paste secret values into prompts.
- Applying a generic fix without understanding consequences: Deleting a pod, increasing memory, changing probes, or disabling a policy can hide symptoms or cause an outage. Establish the cause and review the proposed effect first.
Tips
- Capture a timestamp and the affected namespace, workload, and pod names before investigating; Kubernetes state can change while you work.
- Use the smallest useful scope, then widen it if the problem crosses namespaces or involves shared services.
- Compare K8sGPT output with Kubernetes-native evidence. For example, a scheduling warning should be checked against pod events and node capacity, not fixed by guessing at resource requests.
- Keep K8sGPT and its provider configuration current according to project documentation, but review changes to permissions and data handling rather than blindly copying setup commands.
- For a production incident, preserve existing incident procedures and escalation paths. A diagnostic tool complements monitoring and operator judgment; it does not replace them.
Troubleshooting
No findings appear: Confirm the context, namespace, and account permissions. Check whether the affected resource exists and whether the issue is still present. Try a broader analysis, then inspect events and logs directly; not every application problem is detectable by a Kubernetes analyzer.
K8sGPT cannot connect or reports an authorization error: Check that kubectl can reach the cluster, your current context is correct, and the account can read the resource types being analyzed. Ask an administrator for narrowly scoped read permissions rather than using a more privileged account as a workaround.
Analysis is slow or returns too much information: Narrow the namespace or resource filters, and check the CLI help for supported options. Large clusters and broad scans can take longer. Analyze a smaller scope first and compare results with targeted kubectl commands.
An AI provider fails or the explanation seems unreliable: Check provider configuration and connectivity using the documentation for your installed release. You can still use local analyzer findings and Kubernetes evidence. Do not send additional data or enable broader access simply to get an answer.
The suggested fix does not resolve the issue: Recheck current events and logs, because the original condition may have changed or the suggestion may be mistaken. Review related dependencies such as image availability, configuration, networking, and node health. Revert a change through the approved process if it causes harm, and escalate when the impact is unclear.
Frequently Asked Questions
Does K8sGPT change my cluster automatically?
Basic analysis is diagnostic. Avoid remediation or write-enabled features unless they are explicitly needed, reviewed, and authorized; keep routine troubleshooting read-only.
Can I use K8sGPT without an AI provider?
Yes. Its analyzers can identify common Kubernetes issues without an external AI explanation. Exact features depend on the installed release and configuration.
Does K8sGPT send cluster data to a provider?
It may send diagnostic information when an AI provider is configured and used. Check the configuration and provider terms, inspect sensitive data, and follow your organization’s policies before doing so.
Should I apply every suggested fix?
No. Treat each suggestion as a hypothesis. Validate it with Kubernetes evidence, assess its effects, and use your normal review and rollback process before changing anything.
What permissions should K8sGPT have?
Use the least privilege needed to read the resources under investigation. Do not grant broad write or cluster-admin permissions for ordinary diagnosis.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- How to Rebrand a Tech Company Without Confusing Customers
- Starbound Spawn Creature Command Not Working? Fixes
- How to Use AI Coding Tools Without Losing Skills
- Evolve Wraith Guide: How the Stealth Assassin Works
- How Foldable Phone Displays and Hinges Work
- AI Workflow Completion Criteria: How to Check Results