K8sGPT 的使用

K8sGPT

介绍

k8sgpt 是一个扫描 Kubernetes 集群、诊断和分类问题的工具。它将 SRE 经验编入其分析器中,并帮助提取最相关的信息,通过人工智能来丰富它。它还可以与 OpenAI、Azure、Cohere、Amazon Bedrock 和本地模型结合使用。
K8sGPT Github 地址

部署 LocalAI

部署 LocalAI

配置 LocalAI

bash 复制代码
k8sgpt auth add --backend localai --model ggml-gpt4all-j --baseurl http://localhost:8080/v1
k8sgpt auth list

测试诊断

部署创建带错误的 deployment

yaml 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        securityContext:
          readOnlyRootFilesystem: true
bash 复制代码
# 部署
kubectl apply -f ./nignx.yaml -n demo
# 诊断
k8sgpt analyze -n demo --explain --backend localai

大概意思是告诉你思路去排查吧,好像还很初级就是了,可以针对自己环境的问题做成文档喂给 AI,锻炼一下,就更有针对性。

安全扫描分析

bash 复制代码
k8sgpt integration list
k8sgpt integration activate trivy
k8sgpt filters list
k8sgpt analyse --filter=VulnerabilityReport
k8sgpt analyze --filter VulnerabilityReport --explain --backend localai

k8sgpt integration deactivate trivy

Operator 使用

部署 operator

bash 复制代码
helm repo add k8sgpt https://charts.k8sgpt.ai/
helm repo update
helm pull k8sgpt/k8sgpt-operator
tar xvf k8sgpt-operator-0.1.0.tgz
cd k8sgpt-operator && vim values.yaml
# 开启 serviceMonitor 和 GrafanaDashboard
serviceMonitor:
	enabled: true
GrafanaDashboard:
	enabled: true
helm install k8sgpt-operator . -n k8sgpt-operator-system --create-namespace

部署 promethues

bash 复制代码
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prom prometheus-community/kube-prometheus-stack -n k8sgpt-operator-system --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
kubectl port-forward service/prom-grafana -n k8sgpt-operator-system 3000:80

配置部署 K8sGPT

bash 复制代码
kubectl apply -f -n k8sgpt-operator-system - << EOF
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
  name: k8sgpt-local-ai
spec:
  ai:
    enabled: true
    model: ggml-gpt4all-j
    backend: localai
    baseUrl: http://192.168.3.39:8080/v1
    anonymized: true
    language: english
    method: /v1
    remote_addr: 192.168.3.39:8080
  noCache: false
  version: v0.3.8
EOF

查看故障报告

bash 复制代码
 kubectl get -n k8sgpt-operator-system result k8sgptoperatorsystemnginxdeployment866dc6df9cn5qqj -o yaml

Grafana 查看对应面板

备注:登陆的账号密码可以查看 secret/prom-grafana

Reference

https://www.youtube.com/watch?v=SX_2YHC15cM\&t=1578s

https://anaisurl.com/k8sgpt-full-tutorial/

https://cloud.tencent.com/developer/article/2311268

https://www.sfernetes.com/k8sgpt/

相关推荐
JasonChen@6667 小时前
prometheus静态监控static_config案例二(8)
grafana·prometheus
如夏倾城13 小时前
入侵检测系统(IDS)原理、部署模式与 IPS/防火墙对比
大数据·网络·人工智能·网络安全·云原生·架构·kubernetes
Z21-X13 小时前
云原生运维学习笔记:Kubernetes Volume 与 Secret 实验
运维·笔记·学习·云原生·kubernetes
分布式存储与RustFS15 小时前
桶里的文件想当目录使:用 ZeroFS 把 RustFS 挂成一棵 POSIX 树
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
分布式存储与RustFS17 小时前
向量表别堆本地盘:用 LanceDB 把数据集建在 RustFS 上
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
mengge.cloud20 小时前
Python基础保姆级!从入门到入土
开发语言·python·云原生·pygame
阿里云云原生2 天前
阿里云 AI 网关 x 联想百应:构建 Token Plan 平台&词元宝 Token Key 产品,让模型服务走向规模化运营
云原生
阿里云云原生2 天前
基于阿里云 AgentLoop 构建 Agent 进化数据飞轮闭环,让线上 Trace 沉淀为可复用经验
云原生
分布式存储与RustFS2 天前
Zeppelin 笔记本重启就丢:三个环境变量把 .zpln 存进 RustFS 桶
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
阿里云云原生2 天前
AgentScope Durable:让企业 Agent 持续、可靠地运行
云原生