K8sGPT
$ k8sgpt 基金会 中风险k8sgpt 运行内置的 Kubernetes 分析器(Pod、Service、Deployment、Ingress、PVC 等)并以 JSON(--output=json)清晰呈现集群故障,还支持可选的 --explain 大模型建议与 --anonymize 敏感信息脱敏。
brew install k8sgpt 编码 Agent 本身已具备大模型推理能力,不加 --explain 直接运行 k8sgpt analyze --output=json 即可零额外 LLM 成本获得确定性集群诊断。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持 --output=json、--filter、--namespace 与可选 --explain 开关,既能纯确定性排查也能附带 AI 解读。
- Supports
--output=json,--filter, and-n <namespace> - Optional
--explainand--anonymizeflags
对 Kubernetes 集群保持只读,但启用 --explain 会将集群报错片段发送至外部 LLM,需配合 --anonymize 或本地模型控制外发风险。
- Read-only Kubernetes API scanning
--explaintransmits cluster metadata to external LLMs unless anonymized
跨 macOS、Linux、Windows 的单文件静态 Go 二进制,可通过 Homebrew 或 GitHub Releases 安装。
- Cross-platform binary via
brew install k8sgpt
一条命令即可串联 Pod、Event、Endpoint 等多资源故障规则,减少 Agent 逐项交叉排查的开销。
- Multi-resource diagnostic analyzers in one pass
CNCF 沙箱项目(k8sgpt-ai/k8sgpt),采用 Apache-2.0 协议。
- CNCF
k8sgpt-ai/k8sgptrepository
docs.k8sgpt.ai 对分析器、鉴权后端与过滤参数均有清晰文档。
- Official docs at docs.k8sgpt.ai
安全边界、鉴权与放权指南
从 ~/.kube/config(KUBECONFIG)读取集群状态,并通过 k8sgpt auth add 将 LLM 后端配置与密钥保存在系统 XDG 配置目录(k8sgpt.yaml)。
CLI 基于 Apache-2.0 免费开源;开启 --explain 且使用云端模型会产生第三方 Token 费用(本地 Ollama/NoopAI 除外)。
# K8sGPT Agent Rules - Omit `--explain` when the coding agent itself will interpret `k8sgpt analyze --output=json` findings (faster and avoids duplicate LLM billing). - Whenever `--explain` is used with cloud LLMs, ALWAYS pass `--anonymize`. - Pass `--backend`, `--model`, and `--password` explicitly on `k8sgpt auth add` to avoid interactive prompts.
Agent 高频安全命令配方
只读查询(安全推荐)
k8sgpt analyze -n default --filter=Pod,Service --output=json
在本地运行内置 Go 分析器检查集群并以结构化 JSON 输出故障项,无需外部 LLM 调用。
k8sgpt analyze -n default --explain --anonymize --output=json
在请求 LLM 解释前先对敏感名称与字段脱敏,并以结构化 JSON 返回结果。
核心优势
- + 省略
--explain时无需配置任何 LLM 密钥即可运行k8sgpt analyze --output=json。 - + 内置
--anonymize可在请求外部 LLM 前自动脱敏敏感标识。 - + 支持
--filter与--namespace精准聚焦故障范围。
注意事项与踩坑点
- ! 调用
k8sgpt auth add时若未显式传入--backend/--password会触发交互输入。 - ! 对云端模型开启
--explain会产生外部 Token 费用,未加--anonymize时存在元数据外泄风险。