clusterctl
$ clusterctl 基金会 高风险clusterctl 用于管理 Cluster API(CAPI)管理集群,并通过 clusterctl generate cluster 渲染声明式工作负载集群清单;同时支持用 clusterctl describe cluster 展示层级健康树,以及用 clusterctl upgrade plan 执行升级前检查。
brew install clusterctl clusterctl generate 直接在本地渲染可供 kubectl apply 使用的 YAML,而 describe cluster 一条命令即可汇总 CAPI CRD 状态,无需 MCP。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
generate 可输出规范 YAML 且 describe cluster 支持非交互状态树展示,但各子命令普遍缺少 --json 输出参数。
generate clusterprints YAML manifests to stdout- Lacks
--jsonoutput ondescribe clusterandupgrade plan
generate 纯本地只读且 upgrade plan 支持预检,但 init、move 与 delete 会变更管理集群 CRD 且缺少 --dry-run。
generateandupgrade planseparate preview from mutation
跨 macOS、Linux、Windows 的静态 Go 二进制,可通过 Homebrew 或 GitHub Releases 安装。
- Cross-platform binary via
brew install clusterctl
简化 CAPI 提供商部署、模板渲染以及跨集群 move 迁移操作。
- Consolidates multi-CRD CAPI lifecycle and health views
Kubernetes SIG Cluster Lifecycle 官方项目(kubernetes-sigs/cluster-api),Apache-2.0 协议。
- Official
kubernetes-sigs/cluster-apirepository
Cluster API Book 文档体系完善,但不同基础设施提供商所需的模板环境变量差异较大。
- Official Cluster API Book documentation
安全边界、鉴权与放权指南
从 ~/.kube/config(--kubeconfig)读取集群上下文,并从 ~/.cluster-api/clusterctl.yaml 或环境变量读取基础设施提供商凭证与模板变量。
CLI 基于 Apache-2.0 免费开源;生成的工作负载集群将通过所选云厂商创建基础设施并产生费用。
# 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 对象的条件状态。
受控写入与预演
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。