k8sgpt-ai/k8sgpt-operator
Automatic SRE Superpowers within your Kubernetes cluster
k8sgpt‑operator – AI‑powered analysis & auto‑remediation for Kubernetes
What it is – A Kubernetes Operator that runs the K8sGPT engine inside a cluster. It watches the cluster, sends resource data to a configurable LLM (OpenAI, Azure OpenAI, Bedrock, LocalAI, etc.), receives diagnostic suggestions, and can automatically apply safe, single‑step fixes (e.g., replace a failing container image). All LLM calls are read‑only; the operator itself builds the JSON‑patch and applies it after a policy‑gate and dry‑run.
Key features
- Auto‑remediation (alpha, opt‑in) – Detects failures like
ImagePullBackOff, asks the LLM for a fix, generates a semantic patch, dry‑runs it, and rolls out the corrected workload. The LLM never has write permissions. - Multi‑cluster monitoring – By supplying a
kubeconfigsecret the operator can manage remote clusters from a central “seed” cluster (useful for Cluster‑API fleets). - Pluggable AI back‑ends – OpenAI, Azure OpenAI, Amazon Bedrock, LocalAI, and any compatible provider via the
spec.ai.backendfield. - Distributed caching – Optional Interplex RPC cache, Azure Blob, or S3 cache to avoid repeated LLM calls.
- Configurable analysis – Interval, resource limits, image pull policy, custom container images, and a rich set of analyzers (core and optional) selectable via
spec.filters. - Result objects – Findings are emitted as
ResultCRDs, labelled with the originating K8sGPT instance, namespace, and backend for easy filtering. - Integrations (sinks) – Send results to Slack, Mattermost, CloudEvents, etc.
Installation (Helm)
helm repo add k8sgpt https://charts.k8sgpt.ai/
helm repo update
helm install release k8sgpt/k8sgpt-operator \
-n k8sgpt-operator-system --create-namespace
Getting started – Create a secret with your LLM credentials, then apply a K8sGPT custom resource. Example for OpenAI:
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
name: k8sgpt-sample
namespace: k8sgpt-operator-system
spec:
ai:
enabled: true
model: gpt-4o-mini
backend: openai
secret:
name: k8sgpt-sample-secret
key: openai-api-key
repository: ghcr.io/k8sgpt-ai/k8sgpt
version: v0.4.32
The operator will spin up the K8sGPT deployment, start scanning, and create Result objects you can view with kubectl get results.
Enabling auto‑remediation – Add the remediation CR (valid_k8sgpt_remediation_sample.yaml) and set spec.autoRemediation.enabled: true. The operator will then attempt one‑image repairs for detected image‑pull failures, subject to the safety gate described above.
Why it matters – It brings LLM‑driven observability and self‑healing to Kubernetes without giving the LLM direct write access, aligning with security best practices while reducing mean‑time‑to‑resolution for common cluster issues.
Related
- Project
- Project
- Project
- Project
- Project