This Operator is designed to enable K8sGPT within a Kubernetes cluster. It will allow you to create a custom resource that defines the behaviour and scope of a managed K8sGPT workload. Analysis and outputs will also be configurable to enable integration into existing workflows.
helm repo add k8sgpt https://charts.k8sgpt.ai/
helm install release k8sgpt/k8sgpt-operator -n k8sgpt-operator-system --create-namespace
-
Install the operator from the Installation section.
-
Create secret:
kubectl create secret generic k8sgpt-sample-secret --from-literal=openai-api-key=$OPENAI_TOKEN -n k8sgpt-
operator-system
- Apply the K8sGPT configuration object:
kubectl apply -f - << EOF
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
name: k8sgpt-sample
namespace: k8sgpt-operator-system
spec:
model: gpt-3.5-turbo
backend: openai
noCache: false
version: v0.3.0
enableAI: true
# filters:
# - Ingress
secret:
name: k8sgpt-sample-secret
key: openai-api-key
EOF
- Once the custom resource has been applied the K8sGPT-deployment will be installed and you will be able to see the Results objects of the analysis after some minutes (if there are any issues in your cluster):
❯ kubectl get results -o json | jq .
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "core.k8sgpt.ai/v1alpha1",
"kind": "Result",
"spec": {
"details": "The error message means that the service in Kubernetes doesn't have any associated endpoints, which should have been labeled with \"control-plane=controller-manager\". \n\nTo solve this issue, you need to add the \"control-plane=controller-manager\" label to the endpoint that matches the service. Once the endpoint is labeled correctly, Kubernetes can associate it with the service, and the error should be resolved.",
AzureOpenAI
-
Install the operator from the Installation section.
-
Create secret:
kubectl create secret generic k8sgpt-sample-secret --from-literal=azure-api-key=$AZURE_TOKEN -n k8sgpt-
operator-system
- Apply the K8sGPT configuration object:
kubectl apply -f - << EOF
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
name: k8sgpt-sample
namespace: k8sgpt-operator-system
spec:
model: gpt-35-turbo
backend: azureopenai
baseUrl: https://k8sgpt.openai.azure.com/
engine: llm
noCache: false
version: v0.3.2
enableAI: true
secret:
name: k8sgpt-sample-secret
key: azure-api-key
EOF
LocalAI
-
Install the operator from the Installation section.
-
Follow the LocalAI installation guide to install LocalAI. (No OpenAI secret is required when using LocalAI).
-
Apply the K8sGPT configuration object:
kubectl apply -f - << EOF
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
name: k8sgpt-local-ai
namespace: default
spec:
model: gpt-3.5-turbo
backend: localai
noCache: false
version: v0.3.0
enableAI: true
EOF
- Same as step 4. in the example above.
For details please see here