migrate-from-kubectl
Use when the user is MIGRATING from ad-hoc `kubectl apply` toward GitOps (Argo / Flux / ConfigHub) — and needs to find the manual edits, decide what to do with each (revert / port to git / accept as canonical), and plan the transition. Natural phrasing: "find all the manual edits in this cluster", "we have years of kubectl-apply, help us move to GitOps", "which resources have been hand-edited?", "audit drift caused by humans not controllers", "port my cluster state to git", "show me everything kubectl-* has touched". Composes attribution layer (`cause: manual-edit`) + `map orphans` (resources without a controller owner) + `scan` (risk classification) + `snapshot` / `import --git-path` preview once a repo skeleton exists. Read-only throughout — the migration itself is user-driven. Do NOT load for: real-time triage (use triage-unhealthy-workload), single-resource drift question (use investigate-drift), a fleet conformance audit (use audit-fleet-conformance), or any mutating action.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 14
- Forks
- 1
01 前言 Front Matter
- name
- migrate-from-kubectl
- phase
- cross-cutting
- description
- Use when the user is MIGRATING from ad-hoc `kubectl apply` toward GitOps (Argo / Flux / ConfigHub) — and needs to find the manual edits, decide what to do with each (revert / port to git / accept as canonical), and plan the transition. Natural phrasing: "find all the manual edits in this cluster", "we have years of kubectl-apply, help us move to GitOps", "which resources have been hand-edited?", "audit drift caused by humans not controllers", "port my cluster state to git", "show me everything kubectl-* has touched". Composes attribution layer (`cause: manual-edit`) + `map orphans` (resources without a controller owner) + `scan` (risk classification) + `snapshot` / `import --git-path` preview once a repo skeleton exists. Read-only throughout — the migration itself is user-driven. Do NOT load for: real-time triage (use triage-unhealthy-workload), single-resource drift question (use investigate-drift), a fleet conformance audit (use audit-fleet-conformance), or any mutating action.
- allowed-tools
- Bash(./cub-scout map list *) Bash(./cub-scout map workloads *) Bash(./cub-scout map orphans *) Bash(cub-scout map list *) Bash(cub-scout map workloads *) Bash(cub-scout map orphans *) Bash(cub scout map list *) Bash(cub scout map workloads *) Bash(cub scout map orphans *) Bash(./cub-scout scan *) Bash(cub-scout scan *) Bash(cub scout scan *) Bash(./cub-scout compare drift *) Bash(cub-scout compare drift *) Bash(cub scout compare drift *) Bash(./cub-scout compare three-way *) Bash(cub-scout compare three-way *) Bash(cub scout compare three-way *) Bash(./cub-scout explain *) Bash(cub-scout explain *) Bash(cub scout explain *) Bash(./cub-scout trace *) Bash(cub-scout trace *) Bash(cub scout trace *) Bash(./cub-scout snapshot *) Bash(cub-scout snapshot *) Bash(cub scout snapshot *) Bash(./cub-scout receipt verify *) Bash(cub-scout receipt verify *) Bash(cub scout receipt verify *) Bash(kubectl get *) Bash(kubectl describe *) Bash(kubectl get --show-managed-fields *)
02 资源文件 1
- 参考文档agents/openai.yaml114 B
03 SKILL.md 正文
migrate-from-kubectl
The legacy-cluster migration loop. A cluster has accumulated kubectl apply -f over years; the team wants to adopt GitOps (Argo / Flux / ConfigHub). Step 1 of that migration is finding what's been hand-touched and deciding per-resource: revert, port to git, or accept as canonical.
This skill composes the attribution layer (cause: manual-edit), map orphans, scan, and snapshot / import --git-path preview once a repo skeleton exists. Read-only throughout — the actual migration is user-driven.
When to use
Explicit phrasings:
- "Find all the manual edits in this cluster"
- "We have years of kubectl-apply, help us move to GitOps"
- "Which resources have been hand-edited?"
- "Audit drift caused by humans (not controllers)"
- "Port my cluster state to git" / "scaffold ConfigHub for our legacy cluster"
- "Show me everything
kubectl-*has touched" - "Triage the migration backlog — which resources to handle first?"
Implicit intents:
- The user is before GitOps adoption (no Argo/Flux/ConfigHub for most resources yet)
- The user wants a per-resource plan (revert / port / accept), not a single fix
- The user is gating on risk — what's safe to migrate first, what's risky
- The user may not know which resources even need migration ("show me what's manual")
Do not load for
- Real-time triage of a broken workload —
triage-unhealthy-workload - Single-resource drift question (
why is THIS one different?) —investigate-drift - Fleet conformance audit once GitOps is in place —
audit-fleet-conformance - Preview an import proposal from an existing repo —
prepare-for-confighub(closely related; that skill assumes the repo exists; this one assumes it doesn't yet) - Any mutating action. cub-scout never mutates. Every revert / port / accept is user-driven.
The loop
- Inventory. What workloads exist? Who (if anyone) owns each? Which are GitOps-managed already, which are
OwnerType=unknown? - Classify. For each non-GitOps resource, read
managedFieldsfor the last writer. If akubectl-*writer wrote it, this is amanual-editcandidate. - Risk-rank.
scanproduces severity-ranked findings. Use it to prioritize: high-severity / production-namespace resources first. - Per-resource decision. For each
manual-editresource, decide: revert (let a future controller reconcile), port to git (commit current state + plan controller adoption), or accept as canonical (and then port). - Scaffold the git side. Once decisions are made, snapshot the cluster (
snapshot→ GSF JSON). If you have already created a git layout, useimport --git-path --dry-run --jsonto preview what ConfigHub would infer from it. - Persist baseline receipts.
receipt verify <kind>/<name> --since <migration-start-time>per resource — captures the pre-migration baseline as fingerprinted evidence. Useful when the migration is contested ("did we really revert that?").
Step-by-step
Step 1 — inventory
$ cub-scout map --format json | jq 'group_by(.ownership.type) | map({type: .[0].ownership.type, count: length})'
[
{"type": "argo", "count": 12},
{"type": "flux", "count": 5},
{"type": "helm", "count": 8},
{"type": "k8s", "count": 47}, # native chains (ReplicaSets etc.) — fine
{"type": "unknown", "count": 23} # ← the migration backlog
]
The 23 OwnerType=unknown resources are the candidates. Some are ad-hoc applies that should adopt GitOps; some might be orphans whose original owner is gone.
Step 2 — classify by writer
For each unknown-owned resource, read the last writer:
$ for r in $(cub-scout map --format json | jq -r '.[] | select(.ownership.type == "unknown") | "\(.kind)/\(.name)|\(.namespace)"'); do
kind=$(echo "$r" | cut -d/ -f1); rest=${r#*/}; name=${rest%|*}; ns=${rest#*|}
last=$(kubectl get "$kind" "$name" -n "$ns" -o jsonpath='{.metadata.managedFields[-1:].manager}')
echo "$kind/$name in $ns ← $last"
done
Group by writer:
| Writer | Population | Plan |
|---|---|---|
kubectl-edit |
High-touch operator resources | High-risk migration; investigate per-resource |
kubectl-apply / kubectl-client-side-apply |
Bulk applies | Likely the legacy kubectl apply -f *.yaml pattern; group by similar paths |
kubectl-patch / kubectl-create / kubectl-replace |
Ad-hoc surgery | Audit; many of these are emergency fixes that should be in git |
kubectl-last-applied |
CSA migration artifacts | Usually safe to ignore; the resource has the last-applied-configuration annotation |
| Anything else (custom Helm wrappers, in-house controllers) | Unknown | File an issue with the writer string; cub-scout's verified enumeration may not include it yet |
cub-scout explain <kind>/<name> -n <ns> gives the same writer info in human form per resource.
Step 3 — risk-rank
$ cub-scout scan --format json | jq '.findings | sort_by(.severity) | reverse | .[:10]'
scan returns risk findings: severity (error / warning / info), the rule that triggered, and the resource. Use it to prioritize the migration backlog:
severity=error+ production namespace → migrate FIRSTseverity=warning+ multi-replica deployment → nextseverity=infoor single-pod jobs → defer
scan complements the writer-classification: a kubectl-apply to a production deployment is much higher priority than the same writer on a one-off CronJob.
Step 4 — per-resource decision
For each high-priority resource:
| Decision | When to pick it | Migration step (user-driven) |
|---|---|---|
| Revert | The manual edit was wrong (emergency hack, mistaken) | Find the original spec (git history? snapshot?). kubectl rollout undo or kubectl apply -f original.yaml. Eventually adopt GitOps. |
| Port to git | The manual edit is correct AND should be reproducible | kubectl get <kind>/<name> -o yaml > apps/.../resource.yaml; commit; eventually adopt Argo/Flux/ConfigHub for this directory. |
| Accept as canonical | The manual edit IS the source of truth; nothing in git matches | Snapshot the resource (kubectl get or cub-scout snapshot); commit the snapshot; treat the file as authoritative going forward. |
cub-scout doesn't pick. The user does — but cub-scout's evidence makes the decision well-informed (you know exactly which fields were edited, which writer touched them, and whether a controller would have set them differently).
Step 5 — scaffold the git side
For workloads adopting Argo / Flux / ConfigHub:
# Snapshot the current state as a starting point
$ cub-scout snapshot -n payments --format gsf > snapshot-payments.json
# Or, if you already have a repo skeleton, preview what ConfigHub would propose
$ cub-scout import --git-path ./proposed-repo --dry-run --json > proposed-units.json
See prepare-for-confighub for the import-preview flow once you have the repo skeleton.
Step 6 — persist baseline receipts
$ MIGRATION_START="2026-05-22T00:00:00Z"
$ for r in $(cub-scout map --format json | jq -r '.[] | select(.ownership.type == "unknown") | "\(.kind)/\(.name) -n \(.namespace)"'); do
cub-scout receipt verify $r --since $MIGRATION_START --save
done
$ cub-scout receipt list --format json > migration-baseline.json
Each receipt captures "no kubectl-* writer touched this resource after $MIGRATION_START" — a verifiable baseline. If a stakeholder later disputes the migration (we agreed not to touch X), the receipts are the evidence.
See scout-verify for the receipt surface.
Worked example
A team has a small payments namespace with 8 deployments, no GitOps. They want to adopt Argo CD.
$ cub-scout map -n payments --format json | jq '[.[] | {kind, name, owner: .ownership.type}]'
[
{"kind": "Deployment", "name": "api", "owner": "unknown"},
{"kind": "Deployment", "name": "worker", "owner": "unknown"},
{"kind": "Deployment", "name": "scheduler", "owner": "unknown"},
... (8 total) ...
]
$ for d in api worker scheduler; do
cub-scout explain deploy/$d -n payments --presentation ai | grep -E "(Owner|Last writer|Mutation cause)"
done
Owner: Unknown (no GitOps labels, no ownerReferences)
Last writer: kubectl (manager: kubectl-client-side-apply)
Mutation cause: manual-edit
Owner: Unknown (...)
Last writer: kubectl-edit
Mutation cause: manual-edit
Owner: Unknown (...)
Last writer: kubectl-patch
Mutation cause: manual-edit
$ cub-scout scan -n payments --format json | jq '.findings[] | select(.severity == "error")'
{"resource": "Deployment/api", "rule": "no-resource-requests", "severity": "error"}
# Migration plan emerges:
# - api: revert the manual patches (probably emergency tuning), then commit a clean version to git
# - worker: port to git as-is (the manual edits look intentional)
# - scheduler: accept as canonical, document the policy exception
# Scaffold the proposed repo:
$ mkdir -p apps/prod/payments
$ for d in api worker scheduler; do
kubectl get deploy/$d -n payments -o yaml > apps/prod/payments/$d.yaml
done
# Capture baseline receipts:
$ MIGRATION_START="2026-05-22T00:00:00Z"
$ for d in api worker scheduler; do
cub-scout receipt verify deploy/$d -n payments --since $MIGRATION_START --save
done
The user now has: a snapshot of current state in ./apps/prod/payments/, a per-resource migration decision, and 3 baseline receipts confirming the pre-migration state. The actual revert / commit / Argo Application creation is user-driven from here.
Tool boundary
- Allowed: map / map orphans / scan / explain / trace / compare drift / compare three-way (for resources that DO have a controller); snapshot; import --git-path (preview-only — apply is out of band; not auto-approved, because a later
--git-path=would clear the path and turn it into a real import); receipt verify (specificallyno-manual-edits-sincefor baselines); kubectl get / describe / managedFields reads. - Not allowed:
kubectl apply/edit/patch/delete(the actual port / revert is user-driven);cub-scout import apply;argocd app create(creating the Argo Application is user-driven);cubmutations. The migration itself is mutation; this skill stops at evidence + scaffolding.
References
scout-observe— map / scan / snapshotscout-attribute—causefield readingscout-verify— baseline receiptsprepare-for-confighub— once you have the repo skeletonobserve-native— theOwnerType=unknownpopulationreferences/verified-manager-strings.md— writer enumerationmap orphansis the verb for stale-label orphans (different fromOwnerType=unknown); see scout-observe
Constraints
- The actual port / revert / accept-as-canonical is always user-driven. cub-scout produces the evidence; the operator runs the mutation.
cause=unknown(nokubectl-*writer, but no controller signal either) is a separate category frommanual-edit. The migration plan forunknownresources is "investigate why no managedFields signal" — typically an admission webhook stripped them.- Baseline receipts are most useful when captured before the migration starts. Capture them as Step 6, not after the fact.
- For Helm / Kustomize / templated sources, snapshot +
import --git-pathproduces low-confidence proposals; the rendering reconstruction is out of scope. Plan for additional manual review of the proposal in those cases.
04 同仓库更多 Skills
异常工作负载故障分诊
triage-unhealthy-workload
当用户需要在时间压力下应对出现故障的 Kubernetes 工作负载时使用——例如寻呼告警响起、CI 飘红、“生产环境挂了”的场景。自然表述包括:“deploy/api 出现 CrashLoopBackOff,该怎么办?”“发布卡住了,帮帮我”“这个 pod 起不来”“支付服务触发了寻呼告警”“argocd 里全红了”“我应该先检查什么?”“给我一份针对这个工作负载的分诊方案”。它将 doctor → explain → trace 组合成一个紧凑的约 30 秒循环,运维人员可在已确认寻呼告警的上下文中执行。不要用于:没有紧迫性的计划性排查(直接使用 scout-diagnose)、漂移相关问题(使用 investigate-drift),或任何变更操作(cub-scout 从不做变更——应由用户主导,转由 kubectl 处理)。
资源证据收据生成与校验
scout-verify
当用户需要针对某个 Kubernetes 资源生成带类型、带指纹、不可篡改(TYPED、FINGERPRINTED、IMMUTABLE)的证据工件时使用——即 cub-scout 的 Verify 动词组(在 #446 中发布的收据能力)。自然表述包括:“出具一份证明此资源合规的收据”“给我一份证明集群与 Git 一致的证明”“我需要一份可用于审计跟踪的可验证记录”“生成一份收据,证明自部署以来没有人工改动”“对照事实源(source-truth)校验 deploy/api 并保存工件”“验证此收据未被篡改”“展示我们有哪些收据”“此收据是否被篡改过?”“把证据附加到我的 CI 关卡”。当意图涉及 receipt / attestation / evidence-artifact / tamper-evident-record / verified-record / audit-trail / postmortem-evidence / acceptance-judge-input 时均应加载。不要用于:不落盘工件的实时比对(使用 scout-compare)、解读单个字段的来源出处(使用 scout-attribute),或真正实施修复(cub-scout 从不做变更——应由用户主导,转由 cub / argocd / kubectl 处理)。
scout-observe
Use when the user wants to SEE what is running in a Kubernetes cluster, who owns it, and how it is structured — the read-only Observe verb group of cub-scout. Natural phrasing: "what is running in my cluster?", "give me a map of resources", "who owns this Deployment?", "trace this back to its source", "show me the ownership tree", "scan this cluster for risk", "dump the cluster as JSON", "stream cluster events", "run cub-scout as a bot", "what is the connection status?", "is this cluster healthy?". Load when intent is observe / inventory / map / show / list / trace / scan / dump / stream / bot / health-check over a Kubernetes cluster. Do NOT load for: explaining WHY something is broken (use scout-diagnose), comparing cluster state to intended state (use scout-compare), provenance of individual field values (use scout-attribute), or any action that mutates the cluster (cub-scout never mutates — route to cub or kubectl with the user driving).
scout-mcp
Use when the user wants to expose cub-scout to an AI agent over MCP, wants a deterministic AI-ready snapshot of cluster context, or wants cub-scout running as a read-only event bot — the Integrate verb group. Natural phrasing: "start the MCP server", "expose cub-scout to Claude / Codex / my agent", "give me an AI-ready context pack of this cluster", "set up the MCP gateway", "what MCP tools does cub-scout expose?", "run cub-scout as a bot", "produce JSON context for an LLM to reason about this cluster". Load whenever intent is mcp / mcp-gateway / mcp-serve / context-pack / bot / agent-context / ai-snapshot / llm-context / model-context-protocol. Do NOT load for: actually running a non-integrate verb (those are scout-observe / scout-diagnose / scout-compare / scout-attribute / scout-ingest / scout-govern / scout-verify), or `cub` MCP integration (that's a separate tool surface).
scout-ingest
Use when the user wants to ADOPT existing Kubernetes / GitOps workload structure into ConfigHub after observing the live cluster — the adoption/import verb group of cub-scout. Natural phrasing: "discover workloads in this cluster and propose ConfigHub units", "show me the import proposal before I apply", "import this Argo Application set", "bring my Flux Kustomizations into ConfigHub", "preview what would land in ConfigHub if I imported this repo", "parse my git repo as a ConfigHub import bundle", "import a cluster aggregator", "what would --git-path produce for this repo?". Load whenever intent is adopt / import / ingest / preview / propose / parse-repo / discovery / aggregator / bring-into-confighub / what-would-confighub-see. Do NOT load for: questions about who changed a resource, whether it was edited by hand or drifted (use scout-attribute or investigate-drift); reading an exported `kubectl get -o yaml` dump to answer a question about the cluster (that is not an import); basic live-cluster inventory (use scout-observe), troubleshooting (use scout-diagnose), comparing live state to ConfigHub (use scout-compare), or the actual write to ConfigHub via `cub variant upload` (that is `cub`, not cub-scout — route to cub skills). Important: `cub-scout import apply` IS the mutating write into ConfigHub — this skill teaches the read-only preview path and explicitly refuses to invoke `import apply` itself.
ConfigHub 治理信号查询
scout-govern
当用户希望从 cub-scout 获取已连接的(CONNECTED)ConfigHub 治理信号时使用该技能 —— Govern(治理)动词组。自然表述:"给我看这个单元的 ChangeSet 历史"、"如果我修改这个单元,影响范围(blast radius)有多大?"、"我的机群中哪些集群是异常值?"、"给我看昨天的连接摘要"、"在整个机群中呈现这个视图"、"审计谁修改了这个"、"上一次应用来自哪里?"、"列出我拥有的 ConfigHub bundle"、"给我看过往快照的目录"。当意图为历史 / 影响 / 影响范围 / 机群异常 / 摘要 / 视图 / 审计 / bundle / 目录 / 连接上下文时加载。不要用于:实时集群比较(使用 scout-compare)、回执(使用 scout-verify)、正在运行的 Pod 清单(使用 scout-observe),或通过 cub 进行的任何修改。该技能的大部分功能需要 `cub auth login` —— 请提前说明。