KOP Recipes - K8sGPT Operator - Rafay Product Documentation

Configure

In this section, you will create a standardized cluster blueprint with the k8sgpt add-on. You can then reuse this blueprint with all your clusters.

Step 1: Create Namespace

In this step, you will create a namespace for the K8sGPT Operator.

Note: The k8sgpt operator prefers to be deployed into the "kube-system" namespace. This namespace is a privileged namespace on Kubernetes clusters.


Step 2: Create Repository

In this step, you will create a repository in your project so that the controller can retrieve the K8sGPT Operator Helm chart automatically. This allows you to update the add-on to new versions of the K8sGPT operator as and when they are made available.

Optionally, you can click on the validate button on the repo to confirm connectivity.


Step 3: Create K8sGPT Operator Addon

In this step, you will create a custom add-on for the K8sGPT Operator that will pull the Helm chart from the previously created repository. This add-on will be added to a custom cluster blueprint in a later step.


Step 4: Create K8sGPT Configuration Addon

In this step, you will create a custom add-on for the K8sGPT configuration. This add-on will be added to a custom cluster blueprint in a later step.

Note: This configuration contains setting such as the ML model type, whether you are using OpenAI or a local LLM etc.

apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
  name: k8sgpt-sample
  namespace: kube-system
spec:
  model: gpt-3.5-turbo
  backend: openai
  noCache: false
  version: v0.3.0
  enableAI: true
  secret:
    name: k8sgpt-sample-secret
    key: openai-api-key

Step 5: Create K8sGPT Secret

In this step, you will create a Kubernetes secret for K8sGPT which contains the OpenAI API token. This token allows K8sGPT to communicate with your OpenAI account.

kubectl create secret generic k8sgpt-sample-secret --from-literal=openai-api-key=<OPENAI_TOKEN> -n kube-system

Step 6: Create Blueprint

In this step, you will create a custom cluster blueprint that contains the K8sGPT Operator add-on and the K8SGPT configuration add-on that were previously created. The cluster blueprint can be applied to one or multiple clusters.


Step 7: Apply Blueprint

In this step, you will apply the previously created cluster blueprint to an existing cluster. The blueprint will deploy the K8sGPT add-ons to the cluster.

The controller will publish and reconcile the blueprint on the target cluster. This can take a few seconds to complete.


Next Step

At this point, you have done everything required to get K8sGPT configured and operational on your cluster. In the next step, we will test if K8sGPT can detect and identify issues with problematic workloads.