--- 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=`, 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: ` and stop. - `forbidden` on Flux kinds → return `no Flux read access: ` 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 [name] [-A] [--status-selector ready=false] [--show-source]` | Read | status of sources, Kustomizations, HelmReleases | | `flux events --for / -n [--types warning]` | Read | recent controller events | | `flux logs --kind --name -n --level error --since ` | Read | controller errors for one object | | `flux tree kustomization -n [--compact]` | Read | what a Kustomization manages | | `flux trace -n ` | 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 -n -o jsonpath=…` | Read | exact status fields | | `kubectl wait / -n --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 --path --kustomization-file --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.