Command-line applications
Troubleshoot exposes its collection, preflight, and analysis capabilities through command-line applications. The support-bundle CLI is the main operator surface for end-to-end bundle work, while preflight, collect, and analyze provide focused workflows for automation and for running one stage on its own.
Command surface
The command surface separates full troubleshooting work from focused tasks. Operators can use the unified CLI for a complete support-bundle workflow or choose a dedicated executable when a pipeline needs only preflight checks, collection, or analysis.
Unified support-bundle CLI
The support-bundle executable loads support-bundle specifications from cluster objects, local input, standard input, or remote URLs. It combines the loaded instructions with optional auto-discovery and then produces a support bundle with collected data and analyzer results. With the same executable, operators can also redact, compare, upload, schedule, lint, or inspect bundles and specifications. See Unified command routing for the command tree and its routing rules.
References: cmd/…/main.go• L1-10 cmd/…/root.go• L22-36 cmd/…/root.go• L108-116 cmd/…/run.go• L367-491
Dedicated workflow executables
The dedicated executables expose one main workflow without requiring the full unified command surface. preflight checks whether a cluster meets application requirements. collect runs one host or remote collector and prints its result. analyze evaluates a saved support bundle with analyzer definitions and can use either the standard analysis path or optional advanced agents. See Standalone collector and analyzer CLIs for the focused collect and analyze workflows.
| Executable | Primary purpose | Main input and output |
|---|---|---|
preflight | Check cluster readiness before install or upgrade | A preflight spec from a URL, file, or standard input; check results in the selected output form |
collect | Run one collector outside a full bundle run | A host or remote collector spec; collector result JSON on standard output |
analyze | Analyze an existing support bundle | A bundle path and optional analyzer definitions; human-readable or JSON analysis results |
References: cmd/…/root.go• L22-34 cmd/…/root.go• L15-20 cmd/…/collectors_common.go• L1-7 cmd/…/root.go• L32-38 cmd/…/run.go• L29-64
Shared operator contract
All four applications use command flags for workflow choices and support environment-based configuration. Their output is designed for two audiences: interactive operators receive progress and readable results, while automation can request machine-readable output and act on process status. The unified CLI and preflight also support profiling, logging, tracing, and optional self-update checks at the application boundary.
The executable names matter when configuring automation. The unified CLI reads TROUBLESHOOT_* environment settings, while preflight reads PREFLIGHT_*; the standalone collect and analyze applications use the Troubleshoot prefix for their settings. Build targets produce the four binaries as separate entry points.
References: cmd/…/root.go• L38-69 cmd/…/root.go• L176-194 cmd/…/root.go• L37-65 cmd/…/root.go• L123-149 cmd/…/root.go• L22-33 cmd/…/root.go• L39-48 Makefile• L117-143
Workflow boundaries
The applications share Troubleshoot specifications and bundle data, but they do not all start from the same point. A full run collects and may analyze data, a preflight run checks readiness before deployment, and the standalone tools let automation isolate collection or analysis.
Support-bundle lifecycle
The support-bundle lifecycle turns one or more specification sources into a portable troubleshooting record. It can add discovered collectors, apply data protection choices, run collection and analysis, and leave the operator with a local archive or an uploaded result.
This diagram shows the main path from operator input to bundle delivery.
flowchart LR
A[Spec sources] --> B[Load and merge specs]
B --> C{Auto-discovery enabled?}
C -->|Yes| D[Add foundational collectors]
C -->|No| E[Use declared collectors]
D --> F[Collect and analyze]
E --> F
F --> G[Redact or tokenize data]
G --> H[Write support bundle]
H --> I{Upload requested?}
I -->|Yes| J[Upload for analysis]
I -->|No| K[Return local archive and results]
The root command chooses cluster specs when no source argument is given. It also accepts explicit sources such as a Secret, ConfigMap, file, standard input, or URL. The resulting specs are merged before the run so that one invocation can combine declared collectors, host collectors, analyzers, and redactors.
References: cmd/…/root.go• L22-36 cmd/…/root.go• L71-99 cmd/…/run.go• L55-100 cmd/…/run.go• L243-316 cmd/…/run.go• L367-491
Preflight readiness checks
The preflight executable is the early gate in an application lifecycle. It runs checks against a cluster before an application is installed or upgraded, so it requires the caller to provide the spec rather than discovering specs inside the cluster. Its command family also prepares specs for that check by rendering templates, extracting requirement text, converting older specs, fetching OCI content, and linting input.
The normal preflight path is separate from support-bundle collection because its result answers “can this application run here?” rather than “what evidence should we send for troubleshooting?”. The same executable can therefore serve both a human release check and a CI or installer gate.
References: cmd/…/root.go• L22-34 cmd/…/root.go• L67-82 cmd/…/root.go• L91-110 cmd/…/template.go• L8-40 cmd/…/docs.go• L19-61 cmd/…/convert.go• L15-38 cmd/…/oci_fetch.go• L13-33 cmd/…/lint.go• L15-49
Standalone collection and analysis
The collect and analyze executables split the bundle lifecycle into reusable automation steps. collect accepts a single host or remote collector spec and writes the native result to standard output, which makes it suitable for a collector that runs in a pod or another controlled execution point. analyze accepts an existing bundle and analyzer definitions, then reports pass, warning, fail, and error outcomes without collecting new data.
The standalone analyzer has two broad modes. Its legacy path preserves the original analyzer behavior, while its advanced path can combine local and optional Ollama-backed analysis agents. Utility flags manage the local Ollama service and models without requiring a bundle, which supports setup in a separate automation step.
References: cmd/…/run.go• L30-89 cmd/…/run.go• L158-188 cmd/…/stdout_results.go• L20-39 cmd/…/run.go• L29-64 cmd/…/run.go• L230-331 cmd/…/run.go• L404-457
Unified command capabilities
The unified CLI keeps related post-processing and operational actions beside the main collection command. These actions operate on specifications or already-created bundles, so they can be used as individual steps in a support workflow.
Bundle post-processing
support-bundle redact creates a new archive after applying additional redaction rules to an existing bundle. support-bundle diff compares two archives and reports added, removed, or changed content with impact and optional inline detail. support-bundle upload sends a bundle to the vendor analysis service and can infer upload identity from bundle data when the caller does not provide it.
These commands form a useful handoff path: an operator can protect a bundle, inspect change over time, and then send the selected archive for analysis. The commands keep the original bundle separate from the derived redacted archive or report.
References: cmd/…/redact.go• L16-29 cmd/…/redact.go• L34-71 cmd/…/diff.go• L77-110 cmd/…/diff.go• L651-678 cmd/…/upload.go• L12-32 cmd/…/upload.go• L33-52
Specification quality and scheduling
support-bundle lint checks support-bundle and preflight specifications for syntax and structural problems before a run. support-bundle schedule stores named collection jobs and provides commands to create, list, delete, and activate them through a scheduler daemon. Together, these capabilities move quality checks before execution and recurring collection out of a manual session.
References: cmd/…/lint.go• L15-49 cmd/…/lint.go• L53-99 pkg/…/cli.go• L11-29 pkg/…/cli.go• L32-88 pkg/…/cli.go• L91-170
Change checklist
When these files or sections are changed, remember to consider these:
- If a command name or executable changes, update the build targets and every automation path that selects
support-bundle,preflight,collect, oranalyze. - If an output shape or format changes, check both interactive output and machine-readable consumers. The standalone collector output is a direct contract for pod and remote-collector use.
- If a spec source changes, check the source rules for the unified CLI, preflight, and standalone collector separately. They do not have identical discovery behavior.
- If a flag or environment prefix changes, check the corresponding root command binding and deployment scripts that set
TROUBLESHOOT_*orPREFLIGHT_*values. - If a support-bundle archive or analyzer result changes, check the redact, diff, upload, and standalone analysis handoffs that consume that artifact.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
Running support-bundle with no usable collectors and without auto-discovery | The command stops before collection because there is no work to run | Provide a valid support-bundle or collector spec, or enable auto-discovery |
Running preflight without a source spec | The readiness check cannot start because preflight does not discover specs from the cluster | Pass a URL, file, or standard-input source |
Requesting advanced analyze mode with no available analysis agent | Analysis stops before results are produced | Keep the local agent available or configure a working Ollama agent and model |
Passing an unsupported output format to collect | The collector may run but the CLI cannot serialize the result for the requested contract | Use json or the supported host-only raw format |
Passing a non-archive path to support-bundle diff | Comparison stops before reading bundle content | Use existing .tar.gz or .tgz bundle files |
| Enabling redaction-map encryption without a redaction map | The support-bundle command rejects the tokenization configuration | Provide --redaction-map with encryption or disable encryption |
Key files
| File | Why to read it |
|---|---|
| cmd/…/root.go | Defines the unified support-bundle command and its child command surface. |
| cmd/…/run.go | Shows how unified CLI inputs become a merged support-bundle run and final archive. |
| cmd/…/root.go | Defines the preflight executable boundary and its readiness-check command family. |
| cmd/…/root.go | Defines the standalone collector entry point and per-collector command boundary. |
| cmd/…/run.go | Shows the standalone collector input and result flow. |
| cmd/…/stdout_results.go | Defines the stdout result contract used by collector automation. |
| cmd/…/root.go | Defines the standalone analyzer entry point and analysis flags. |
| cmd/…/run.go | Shows the legacy and advanced analysis paths and their result handoff. |
| pkg/…/cli.go | Defines scheduled support-bundle job management under the unified CLI. |
Makefile | Maps the four command applications to their build targets. |