K8sGPT: The Ultimate Tool for Kubernetes Scanning

K8sGPT: The Ultimate Tool for Kubernetes Scanning

With all the hype around AI these days, you might have encountered hundreds of AI-based tools that can help make your life easier. Be it either SEO optimization using AI or tools that can generate images with just one sentence, there's a lot of innovation around AI these days.

Now, being a DevOps enthusiast, I have faced hundreds of issues and errors while working with Kubernetes and if you are a beginner in DevOps or an experienced person, you must have faced different kinds of problems with your workloads too.
What if I tell you that there's a tool that can help you with scanning your Kubernetes clusters, searching for common issues and problems, and providing accurate diagnoses of the errors based on codified SRE experience with the help of AI?

Let me introduce you to K8sGPT.

What is K8sGPT?

According to the definition

k8sgpt is a tool for scanning your kubernetes clusters, diagnosing and triaging issues in simple english. It has SRE experience codified into it’s analyzers and helps to pull out the most relevant information to enrich it with AI.

Sounds cool right? Getting SRE superpowers with a help of a tool that can find problems in your Kubernetes environment and solve them.

K8sGPT has recently been submitted as a sandbox project to the Cloud Native Computing Foundation (CNCF), demonstrating its potential as a valuable tool for the Cloud Native community. It is in the early stages of being evaluated by the CNCF, but this is a promising step forward that demonstrates the commitment to developing a tool that meets the needs of Kubernetes users.

How does it work?

K8sGPT uses a set of analyzers that are designed to identify and simplify the process of diagnosing and triaging issues in Kubernetes clusters. These analyzers are codified with SRE experience which helps in giving out the most accurate and relevant information.

Here are some of the built-in analyzers:

  1. PodAnalyzer: This analyzer inspects the configuration of pods and checks for any issues that may lead to problems such as pod crashes or resource over-utilization.

  2. PVCAnalyzer: This analyzer inspects the configuration of Persistent Volume Claims (PVCs) and checks for any issues that may cause data loss or other storage-related issues.

  3. ServiceAnalyzer: This analyzer inspects the configuration of Services and checks for any issues that may lead to service downtime or performance degradation.

  4. DeploymentAnalyzer: This analyzer inspects the configuration of Deployments and checks for any issues that may lead to under or over-utilization of resources.

  5. NodeAnalyzer: This analyzer inspects the nodes in the Kubernetes cluster and checks for any issues related to node health, utilization, and capacity.

You can have a look at the rest of the analyzers over here.

For the AI Backend, K8sGPT uses OpenAI as the default backend. You can switch to some other backend such as Azure OpenAI provider, or the FakeAI provider.

How K8sGPT helped me?

  1. Diagnose issues within Kubernetes clusters: K8sGPT helped me to analyze logs and other data from my Kubernetes cluster to identify potential issues. This can help you and especially the SRE, Platform, and DevOps engineers quickly understand what is going on in their cluster and find the root cause of an issue.

  2. Triage issues within Kubernetes clusters: K8sGPT is focused on triaging and diagnosing issues in your cluster. It helped me to cut through the noise of logs and multiple tools to find the root cause of an issue.

  3. Improve the reliability of your Kubernetes cluster: By using K8sGPT to regularly analyze the health of your Kubernetes cluster, I was able to proactively identify and address issues before they cause downtime or other problems.

  4. Troubleshoot a specific resource: Let's say you're experiencing an issue with a particular resource, such as a service or deployment, or in a specific namespace, K8sGPT helped me to troubleshoot a specific resource or a specific namespace easily.

  5. Anonymize your data: During the analysis, K8sGPT retrieves data that can contain sensitive information like Pod names, Namespaces, Resource names, etc that are sometimes classified as strictly confidential to a specific group or even more restrictive individual person (C3, C4 data classification). K8sGPT provides you a feature to easily anonymize this data by masking it when being sent to an AI backend and replacing it with a key that can be used to de-anonymize the data when the solution is returned to the user.

How to use it?


K8sGPT can be installed as a CLI (Command line interface) tool or as an operator within your Kubernetes cluster. We'll be going with the CLI this time, if you wish to install the operator, you can follow the steps mentioned here.

Install in Linux/Mac:

brew tap k8sgpt-ai/k8sgpt
brew install k8sgpt

For other installation methods such as RPM/DEB/APK, refer to here.


A running Kubernetes cluster. You can opt for minikube or Kind if you wish to go for a local Kubernetes cluster.

Quick start

  1. You will need an API key from OpenAI as the default AI provider is set to OpenAI. The following command will redirect you to the browser link to generate the key.

     k8sgpt generate
  2. Use the following command and set your API key in K8sGPT.

     k8sgpt auth
  3. Run the following command to analyze issues within your Kubernetes cluster.

     k8sgpt analyze

    This command will scan for issues within your Kubernetes clusters. By default, k8sgpt uses all the built-in analyzers to scan the cluster. If there are any issues found, it will return the errors, for example:

  4. You can use the following command to get more detailed information about the errors within your Kubernetes cluster.

     k8sgpt analyze --explain

Additional Flags

  1. You can filter for a particular resource or a namespace using the following command.

     k8sgpt analyze --filter=Service
     k8sgpt analyze --namespace=default
  2. You can set the output to a JSON format using the following command.

     k8sgpt analyze --output=json
  3. You can opt to anonymize your data.

     k8sgpt analyze --anonymize
  4. You can switch to some other AI backend using the following command.

     k8sgpt auth -b <provider>

In the end, K8sGPT is a really powerful tool that helps in saving your time and increasing your efficiency by looking and troubleshooting for errors within your Kubernetes clusters.

If you wish to learn more about K8sGPT, you can visit their GitHub or join their Slack.

Or if you wish to have a chat about Cloud Native, Open Source, or DevOps, you can reach out to me on Twitter or LinkedIn.

Thank you for reading :)

Did you find this article valuable?

Support WeMakeDevs by becoming a sponsor. Any amount is appreciated!