feat(gitops): add flux-diagnose for read-only Flux reconcile checks
flux-diagnose reports source, Kustomization and HelmRelease state, answers "has this commit been applied yet?" with bounded polling (a cap counted in 60-second kubectl wait pauses, never flux reconcile), and walks a failure down the source -> Kustomization -> HelmRelease chain, handing workload problems to k8s-diagnose. Read tier only; it uses the caller's kubeconfig and never looks for credentials. gitops 0.2.0; the package description now covers live reconcile state. Refs: #194 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
67e2523252
commit
2a6eea3db1
6 files changed
+362
-2
No files matched your search
@@ -0,0 +1,78 @@
|
||||
---
|
||||
name: flux-diagnose
|
||||
description: >
|
||||
Use when checking live Flux reconcile state, whether a commit is applied, or why a Flux
|
||||
object fails. Not Flux concepts or YAML -> `gitops-knowledge`. Not repo files ->
|
||||
`gitops-repo-audit`. Not pods -> `k8s-diagnose`. Not app code bugs -> `diagnose`.
|
||||
compatibility: Requires the flux and kubectl CLIs and a kubeconfig from the session or the caller
|
||||
with read access to Flux resources (the built-in view ClusterRole plus Flux's flux-view
|
||||
aggregation).
|
||||
allowed-tools: Bash Read
|
||||
metadata:
|
||||
category: gitops
|
||||
version: "0.1.0"
|
||||
source_keys:
|
||||
- adr-0032-action-tiers
|
||||
- delivery-guard-flux-allowlist
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- A Kustomization that applied a HelmRelease object has not upgraded the release. The Helm
|
||||
upgrade is a separate, later reconcile by helm-controller.
|
||||
- Never pick credentials yourself: no `--kubeconfig`, `--context` or `--server` flag, no
|
||||
`kubectl config use-context`, no reading `~/.kube` or a repo's credential paths.
|
||||
|
||||
## Step 1 — Cluster access gate
|
||||
|
||||
Run every command in the caller's environment. Given a kubeconfig path, prefix each command
|
||||
with `KUBECONFIG=<path>`, since each shell call starts fresh; command forms below omit it.
|
||||
|
||||
Run `flux get kustomizations -A` with no connection flags. Then:
|
||||
|
||||
- No kubeconfig, connection refused, timeout, `Unauthorized`, or a TLS error → return
|
||||
`no cluster access: <first error line>` and stop.
|
||||
- `forbidden` on Flux kinds → return `no Flux read access: <first error line>` and stop.
|
||||
- Kind not found (`no matches for kind`) → return `Flux not installed on this cluster` and stop.
|
||||
- Rows print → keep them; every flow starts from this read.
|
||||
|
||||
## Step 2 — Tiers
|
||||
|
||||
Run only the Read rows, even when a fix is one command away: `flux reconcile`, `suspend` and
|
||||
`resume` look harmless but change what the cluster does. Anything else, listed or not, goes back
|
||||
to the caller as a recommendation.
|
||||
|
||||
| Command | Tier | Use |
|
||||
|---|---|---|
|
||||
| `flux get <kind> [name] [-A] [--status-selector ready=false] [--show-source]` | Read | status of sources, Kustomizations, HelmReleases |
|
||||
| `flux events --for <Kind>/<name> -n <ns> [--types warning]` | Read | recent controller events |
|
||||
| `flux logs --kind <Kind> --name <name> -n <ns> --level error --since <dur>` | Read | controller errors for one object |
|
||||
| `flux tree kustomization <name> -n <ns> [--compact]` | Read | what a Kustomization manages |
|
||||
| `flux trace <kind> <name> -n <ns>` | Read | which Flux object and revision owns a workload |
|
||||
| `flux stats -A` | Read | cluster-wide counts of failing and suspended objects |
|
||||
| `flux check` | Read | controller health; not `--pre` |
|
||||
| `kubectl get <flux-kind> <name> -n <ns> -o jsonpath=…` | Read | exact status fields |
|
||||
| `kubectl wait <flux-kind>/<name> -n <ns> --for=jsonpath=… --timeout=60s` | Read | the bounded pause between polls |
|
||||
| `kubectl config current-context` | Read | the context name for the report; never switch it |
|
||||
| `flux build kustomization <name> --path <dir> --kustomization-file <ks.yaml> --dry-run` | Read | offline build-failure repro |
|
||||
| `rtk git fetch`; `rtk git merge-base --is-ancestor` | Read | revision ancestry |
|
||||
| none | Propose, Apply-by-merge | fixes go back to the caller as findings |
|
||||
| `flux reconcile` | Odd job | not used by this skill; name it as a human's option |
|
||||
| `flux suspend/resume/create/delete/install/bootstrap`, live `flux diff`, `flux export --with-credentials`, `flux debug --show-values/--show-vars`, any Secret read | Never | — |
|
||||
|
||||
## Step 3 — Dispatch
|
||||
|
||||
| Condition | Flow | Reference |
|
||||
|---|---|---|
|
||||
| Caller wants the state of Flux objects, cluster-wide or named | Status | `references/status.md` |
|
||||
| Caller gives a Kustomization and a commit SHA and asks whether it is applied | Applied check | `references/applied-check.md` |
|
||||
| Caller names a failing object or symptom and asks why | Diagnose | `references/diagnose.md` |
|
||||
|
||||
Read only the matching reference; each is self-contained with its own output format.
|
||||
|
||||
## Step 4 — Hand off
|
||||
|
||||
When the chain ends at a workload (a stuck Deployment, failing pods, a failed Helm test, a health
|
||||
check naming a workload), stop walking. Return the Flux finding with the
|
||||
workload's kind, namespace and name, and route the rest to `k8s-diagnose`. Never chase pod logs or
|
||||
node state from this skill.
|
||||
Reference in new issue
Block a user