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

clusterctl

$ clusterctl 基金会 高风险
Kubernetes SIGs · 云原生与基础设施 · Apache-2.0 · macos / linux / windows

clusterctl 用于管理 Cluster API(CAPI)管理集群,并通过 clusterctl generate cluster 渲染声明式工作负载集群清单;同时支持用 clusterctl describe cluster 展示层级健康树,以及用 clusterctl upgrade plan 执行升级前检查。

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

clusterctl generate 直接在本地渲染可供 kubectl apply 使用的 YAML,而 describe cluster 一条命令即可汇总 CAPI CRD 状态,无需 MCP。

Agent 友好度体检单

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

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

FCRS-1.0 六维评分拆解

Agent 友好度 16 / 25

generate 可输出规范 YAML 且 describe cluster 支持非交互状态树展示,但各子命令普遍缺少 --json 输出参数。

  • generate cluster prints YAML manifests to stdout
  • Lacks --json output on describe cluster and upgrade plan
安全与权限边界 19 / 25

generate 纯本地只读且 upgrade plan 支持预检,但 init、move 与 delete 会变更管理集群 CRD 且缺少 --dry-run。

  • generate and upgrade plan separate preview from mutation
安装与运行摩擦 14 / 15

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

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

简化 CAPI 提供商部署、模板渲染以及跨集群 move 迁移操作。

  • Consolidates multi-CRD CAPI lifecycle and health views
维护与来源背书 9 / 10

Kubernetes SIG Cluster Lifecycle 官方项目(kubernetes-sigs/cluster-api),Apache-2.0 协议。

  • Official kubernetes-sigs/cluster-api repository
文档与可验证性 7 / 10

Cluster API Book 文档体系完善,但不同基础设施提供商所需的模板环境变量差异较大。

  • Official Cluster API Book documentation

安全边界、鉴权与放权指南

鉴权方式
本地配置文件 环境变量密钥
凭证存储位置

从 ~/.kube/config(--kubeconfig)读取集群上下文,并从 ~/.cluster-api/clusterctl.yaml 或环境变量读取基础设施提供商凭证与模板变量。

潜在副作用
只读查询 本地写入 远端写入 破坏性删除
费用与配额提示

CLI 基于 Apache-2.0 免费开源;生成的工作负载集群将通过所选云厂商创建基础设施并产生费用。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# clusterctl Agent Rules
- Always pass `--kubeconfig` and `-n <namespace>` explicitly when targeting management clusters.
- Use `clusterctl generate cluster` to inspect manifests locally before piping to `kubectl apply --dry-run=server`.
- Run `clusterctl upgrade plan` before running `clusterctl upgrade apply`.

Agent 高频安全命令配方

只读查询(安全推荐)

在本地渲染工作负载集群清单
clusterctl generate cluster my-workload --infrastructure docker --kubernetes-version v1.31.0 --worker-machine-count 3

向标准输出生成 CAPI 集群 YAML,不会修改任何管理集群状态。

查看工作负载集群健康树
clusterctl describe cluster my-workload -n default --show-conditions all

层级展示 Cluster、ControlPlane 与 Machine 对象的条件状态。

受控写入与预演

在管理集群初始化 CAPI 提供商
clusterctl init --infrastructure docker --kubeconfig ./mgmt.kubeconfig

显式指定管理集群 kubeconfig,安装 Cluster API 核心与基础设施控制器。

核心优势

  • + clusterctl generate cluster 可在应用前于本地完整渲染 CAPI 清单。
  • + clusterctl describe cluster 一览深层嵌套的机器与控制面状态条件。
  • + clusterctl upgrade plan 提供清晰的升级前检查。

注意事项与踩坑点

  • ! describe cluster 与 upgrade plan 无 --json 输出,结构化查询需借助 kubectl get ... -o json。
  • ! clusterctl init 与 move 缺少 --dry-run。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI