CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

K8sGPT

$ k8sgpt 基金会 中风险
K8sGPT / CNCF · 云原生与基础设施 · Apache-2.0 · macos / linux / windows

k8sgpt 运行内置的 Kubernetes 分析器(Pod、Service、Deployment、Ingress、PVC 等)并以 JSON(--output=json)清晰呈现集群故障,还支持可选的 --explain 大模型建议与 --anonymize 敏感信息脱敏。

FCRS-1.0 综合评分
82 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install k8sgpt
CLI vs MCP 选型建议 优先选 CLI

编码 Agent 本身已具备大模型推理能力,不加 --explain 直接运行 k8sgpt analyze --output=json 即可零额外 LLM 成本获得确定性集群诊断。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

支持 --output=json、--filter、--namespace 与可选 --explain 开关,既能纯确定性排查也能附带 AI 解读。

  • Supports --output=json, --filter, and -n <namespace>
  • Optional --explain and --anonymize flags
安全与权限边界 19 / 25

对 Kubernetes 集群保持只读,但启用 --explain 会将集群报错片段发送至外部 LLM,需配合 --anonymize 或本地模型控制外发风险。

  • Read-only Kubernetes API scanning
  • --explain transmits cluster metadata to external LLMs unless anonymized
安装与运行摩擦 14 / 15

跨 macOS、Linux、Windows 的单文件静态 Go 二进制,可通过 Homebrew 或 GitHub Releases 安装。

  • Cross-platform binary via brew install k8sgpt
能力覆盖与边际价值 12 / 15

一条命令即可串联 Pod、Event、Endpoint 等多资源故障规则,减少 Agent 逐项交叉排查的开销。

  • Multi-resource diagnostic analyzers in one pass
维护与来源背书 8 / 10

CNCF 沙箱项目(k8sgpt-ai/k8sgpt),采用 Apache-2.0 协议。

  • CNCF k8sgpt-ai/k8sgpt repository
文档与可验证性 8 / 10

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 除外)。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# 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 高频安全命令配方

只读查询(安全推荐)

不调用 LLM 运行确定性集群诊断并输出 JSON
k8sgpt analyze -n default --filter=Pod,Service --output=json

在本地运行内置 Go 分析器检查集群并以结构化 JSON 输出故障项,无需外部 LLM 调用。

以 JSON 运行脱敏后的 AI 诊断解释
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 时存在元数据外泄风险。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI