0.1.15 • Published 9 months ago

@veecode-platform/backstage-plugin-kubernetes-gpt-analyzer v0.1.15

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
9 months ago

Kubernetes GPT Analyzer ✨

The Kubernetes GPT Analyzer plug-in offers an AI approach to your Kubernetes component.

The plug-in offers a dynamic approach, in conjunction with the @backstage/plugin-kubernetes and k8s-operator:

  • Application error analysis.
  • Listing of errors and their respective solutions, as well as AI suggestions for resolving them.
  • Analysis checking, using a timer that can be configured.

Our community

💬 Join Us

Join our community to resolve questions about our Plugins. We look forward to welcoming you!

  Go to Community  🚀

Getting Started:

Before installing the plugin, there are some prerequisites to ensure its functionality:

Installation

If you are using yarn 3.x:

yarn workspace app add @veecode-platform/backstage-plugin-kubernetes-gpt-analyzer

If you are using other versions:

yarn add --cwd packages/app @veecode-platform/backstage-plugin-kubernetes-gpt-analyzer

Backstage Configuration

Be aware that the ClusterRole used as described at https://backstage.io/docs/features/kubernetes/configuration#role-based-access-control also needs these permissions to read the k8sgpt results:

- apiGroups:
  - core.k8sgpt.ai
  resources:
  - results
  verbs:
  - get
  - list

UI 🎨

In the user interface, we have two approaches: the KubernetesGptAnalyzerCard, which has a more minimalist look, only showing the number of errors if the AI finds them in its analysis, and a button that leads to the KubernetesGptAnalyzerPage component, which is the main component, where, in addition to notifying the number of errors found (if any), it also addresses the errors found and the possibility of analyzing the errors individually, resulting in an analysis with possible solutions. Let's take them one at a time, starting with KubernetesGptAnalyzerCard:

Kubernetes Gpt Analyzer Card

As previously mentioned, the card component is only intended to notify you of errors and has a button that takes you to the main component. To add this card to your EntityPage:

// packages > app > src > components > catalog > EntityPage.tsx

... other imports
+  import {
+   isKubernetesAvailable,  // if you've already imported isKubernetesAvailable from the @backstage/plugin-kubernetes plugin, you don't need to import it again
+   KubernetesGptAnalyzerCard
+  } from '@veecode-platform/backstage-plugin-kubernetes-gpt-analyzer'; 

...

const overviewContent = (
...
+           <Grid item md={7} sm={12}>
+             <KubernetesGptAnalyzerCard />
+            </Grid>
)

image

Kubernetes Gpt Analyzer Page

The main component of the plugin, it shows the number of errors (if any) and the cards with the errors and their respective analyses. To configure:

// packages > app > src > components > catalog > EntityPage.tsx

... other imports
+  import {
+   isKubernetesAvailable,  // if you've already imported isKubernetesAvailable from the @backstage/plugin-kubernetes plugin, you don't need to import it again
+   KubernetesGptAnalyzerPage
+  } from '@veecode-platform/backstage-plugin-kubernetes-gpt-analyzer'; 

// On the entity page you want to add
...
+     <EntityLayout.Route if={isKubernetesAvailable} path="/kubernetes-gpt-analyzer" title="Kubernetes GPT">
+      <KubernetesGptAnalyzerPage />
+    </EntityLayout.Route>
...

ℹ️ Don't change the component's route path to a custom one, it should always be path="/kubernetes-gpt-analyzer".

Screens:

  • When there are errors:

image

  • Analyzing the error:

image

  • When there is no proper configuration:

image

  • When there is no error:

image


Request interval ⏱️

By default, we have determined that analysis requests will have intervals of 1000000 milliseconds, or 16.67 minutes. However, if you need an analysis with shorter or longer intervals, either on the Kubernetes Gpt Analyzer card or on the Kubernetes Gpt Analyzer page, just pass the intervalMs props which expects a number type data:

See:

// Kubernetes Gpt Analyzer Page

   <EntityLayout.Route if={isKubernetesAvailable} path="/kubernetes-gpt-analyzer" title="Kubernetes GPT">
-   <KubernetesGptAnalyzerPage />
+   <KubernetesGptAnalyzerPage intervalsMs={15000} />
   </EntityLayout.Route>

// Kubernetes Gpt Analyzer Card

   <Grid item md={7} sm={12}>
-     <KubernetesGptAnalyzerCard />
+    <KubernetesGptAnalyzerCard intervalsMs={15000} />
   </Grid>
...

ℹ️ Remember that a shorter interval time can increase the consumption of your OPENAI API KEY.