Kamlesh Prajapati
3 min readSep 9, 2024

K8sGPT: Your Personal Kubernetes Assistant Powered by AI Backends

Managing Kubernetes can be complex, requiring significant knowledge and experience. Wouldn’t it be great if you had an intelligent assistant to help you navigate the intricacies of Kubernetes? Introducing K8sGPT, a powerful tool that leverages the capabilities of OpenAI to detect the issues and provide the solution steps, also you can use k8sGPT for vulnerability scanning of you cluster along suggested fixes.

Prerequisites:

What is K8sGPT?

K8sGPT is a tool for scanning your Kubernetes clusters, diagnosing and triaging issues in simple English(its support multiple language e.g french dutch etc). It has SRE experience codified into it’s analyzers and helps to pull out the most relevant information to enrich it with AI. The K8sGPT Operator is ideal for continuous monitoring of your cluster and can integrate with your existing monitoring such as Prometheus and Alertmanager. It detects issues in your kubernetes cluster and uses supported AI backends to recommend solutions for the issues detected.
Best part of k8sGPT is that it bring the AI on terminal, which can reduce your back and forth search time for the fixes of issue.

fig 1.0
Fig 2.0

K8sGPT Architecture:

fig 3.0

Installation:

K8sGPT offers two installation options:

  1. Install k8sgpt as CLI on your workstation
  2. Install k8sgpt as kubernetes operator with your cluster.

For the purpose of this blog, I will focus on the CLI installation on my workstation in WSL, if you’re interested in deploying the k8sgpt operator, you can find the instruction on the documentation.

To install k8sGPT as a CLI on your workstation, please follow the instructions from the official guide here.
Officical document for installtion : https://docs.k8sgpt.ai/getting-started/installation/

Integrate OpenAI With K8sGPT

With our OpenAI , let’s integrate it as a backend for k8sGPT. We will utilize the “k8sgpt auth add” command to seamlessly incorporate the AI backend

Currently, the default AI provider is OpenAI, you will need to generate an API key from OpenAI.
Procedure is same for other openAI backend.

Conclusion:
K8sGPT epitomizes the synergy between Kubernetes and AI. As we embrace its transformative potential, we embark on a journey towards a future where intelligent automation reshapes Kubernetes operations.

Our exploration of K8sGPT has merely touched the tip of its potential. This powerful tool not only enhances Kubernetes operations but also seamlessly integrates with other solutions, such as Trivy for vulnerability management, elevating its capabilities to new heights.

References:
https://github.com/k8sgpt-ai/k8sgpt?tab=readme-ov-file#cli-installation

https://docs.k8sgpt.ai/reference/cli/

Kamlesh Prajapati
Kamlesh Prajapati

Written by Kamlesh Prajapati

DevSecOps Practitioner (CKA certified , RHOCP Certified, Azure Certified on az-104,az-400,az-303.), AIOps , Machine Learning and Deep learning

No responses yet