Introducing a new way to review your PRs.

Read the announcement

replicatedhq / troubleshoot

Preflight Checks and Support Bundles Framework for Kubernetes Applications

View on GitHub

19 documents · Updated Nov 20, 2026

docs / troubleshoot-cli

Unified Troubleshoott CLI

The troubleshoot source entry point builds one user-facing support tool. The built command presents itself as support-bundle and routes users from cluster data collection to analysis, redaction, comparison, upload, validation, and scheduled runs. It combines these product workflows around one support-bundle format while keeping each task available as a separate command.

Command hierarchy

The CLI uses a root command for support-bundle creation and a set of sibling commands for work on existing bundles or specifications. The command tree is the main routing boundary: the root command runs the collection workflow, while each subcommand sends its input to the matching product workflow.

Command tree

The root command accepts zero or more specification locations. Its direct commands cover the main actions that users take before, during, and after a troubleshooting run.

CommandUser goalMain inputMain result
support-bundleCollect and analyze data from a clusterSpecs from a file, URL, OCI source, stdin, Secret, ConfigMap, or the clusterSupport-bundle archive and analysis results
support-bundle analyzeAnalyze an existing archiveAnalyzer spec plus --bundleYAML or JSON analysis results
support-bundle redactApply extra redaction to an archiveRedactor specs plus --bundleA new redacted archive
support-bundle diffCompare two points in timeOld and new support-bundle archivesText or JSON change report
support-bundle uploadSend an archive to the vendor serviceBundle archive and optional license or app dataUpload status
support-bundle lintCheck specs before useOne or more spec filesText or JSON validation results
support-bundle scheduleManage recurring collectionJob name, cron schedule, and collection optionsSaved jobs or daemon activity
support-bundle versionInspect the CLI versionNoneVersion information

The schedule branch has its own hierarchy: create, list, delete, and daemon start. This keeps job setup separate from the process that executes jobs. See command-line applications for the wider CLI family and standalone collector and analyzer CLIs for the separate collect and analyze executables.

References: home/…/main.go• L1-10 home/…/root.go• L22-36 home/…/root.go• L108-116 home/…/analyze.go• L18-24 home/…/redact.go• L16-29 home/…/diff.go• L77-92 home/…/upload.go• L12-32 home/…/lint.go• L15-49 home/…/cli.go• L11-29

Command routing

Each command validates its own arguments and flags, then calls a workflow package. The root command is the only route that creates a support bundle from collection specifications. The other routes start with an existing archive, a specification file, or a saved schedule.

The routing model separates two kinds of work:

  • Bundle creation: the root route loads and combines specs, collects data, analyzes the results, and writes an archive.
  • Bundle operations: analyze, redact, diff, and upload read or transform an archive without starting the root collection flow.
  • Spec and job management: lint checks input before a run, while schedule stores and starts recurring root runs.

This separation lets an operator collect data in one environment, inspect or change it later, and send it to a vendor only when ready. It also gives automation small commands with clear input and output contracts.

References: home/…/root.go• L71-100 home/…/analyze.go• L27-65 home/…/redact.go• L34-72 home/…/diff.go• L96-135 home/…/upload.go• L33-52 home/…/lint.go• L53-99

Root collection workflow

The root route turns one or more troubleshoot specifications into a single collection and analysis run. It uses Kubernetes as the normal target, but it can also use explicit sources so that a user can control which product or cluster rules are active.

Specification intake

The root route accepts specification locations in several forms. The loader gives each form the same next step: parse its content into typed troubleshoot objects before the run starts.

SourceMeaning
Local pathRead a specification from disk.
-Read a specification from standard input.
http:// or https:// URLDownload a specification from a web endpoint.
oci:// URLPull released specifications from an OCI registry.
secret/...Read specification data from a Kubernetes Secret.
configmap/...Read specification data from a Kubernetes ConfigMap.
No locationLoad matching support-bundle specs from the cluster by default.

The loader can combine explicit sources with cluster-loaded sources when the corresponding option is enabled. A support-bundle spec can also point to an upstream URI; the root route resolves that content and folds it into the run unless URI loading is disabled.

References: home/…/specs.go• L72-76 home/…/specs.go• L85-210 home/…/specs.go• L213-237 home/…/root.go• L27-36 home/…/run.go• L367-388

Spec assembly

After intake, the root route combines support-bundle, collector, host-collector, and redactor definitions into one run plan. It removes duplicate entries and adds the normal cluster information and cluster resource collection when the run is not limited to host collection.

The --auto option changes this assembly. With no YAML collectors, the CLI creates a minimal plan and discovers foundational collectors from the target cluster. With YAML collectors, discovery adds foundational coverage to the requested collectors. Profiles control the breadth of discovery, while namespace filters and RBAC checks limit or protect the scan.

This assembly step is also the boundary for --dry-run. Dry run prints the merged plan after source loading and auto-discovery decisions, so it shows what the CLI intends to collect without creating the archive.

References: home/…/run.go• L390-491 home/…/auto_discovery.go• L40-89 home/…/auto_discovery.go• L92-204 home/…/run.go• L84-100

Collection and analysis

The assembled plan moves through collection first and analysis second. Collection gathers cluster and optional host data into the support-bundle archive. Analyzer rules then evaluate the collected files and return pass, warning, or failure results.

The main run supports two user modes:

  • Interactive mode: a terminal spinner shows collection progress, then a terminal view lets the user move through analyzer results with the arrow keys.
  • Non-interactive mode: progress uses log output and the final analysis plus archive path are printed as machine-readable JSON.

The archive remains the durable handoff. A user can send it to a vendor, run analyze later, compare it with another archive, or redact it before sharing. Default redaction runs during collection unless disabled. Tokenization and a protected redaction map can add a reversible mapping for an authorized workflow.

References: home/…/run.go• L102-117 home/…/run.go• L149-245 home/…/run.go• L250-316 home/…/interactive_results.go• L20-62 home/…/collect.go• L88-262

Shared CLI behavior

The root command establishes the common process rules before a workflow runs. These rules make logging, configuration, profiling, Kubernetes access, tracing, and process status behave consistently across the unified command.

Configuration boundary

The CLI reads settings from flags and from environment variables with the TROUBLESHOOT_ prefix. Flag names map to environment names by replacing hyphens with underscores. The same configuration source controls collection choices such as namespace, output path, redaction, auto-discovery, upload, and debug behavior.

Kubernetes connection flags are added at the root boundary. The root collection path turns them into a Kubernetes client configuration before it loads cluster specs or starts collection. A command that needs Kubernetes access therefore depends on both a valid connection and permissions for the requested data.

References: home/…/root.go• L38-43 home/…/root.go• L118-165 home/…/root.go• L191-194 home/…/run.go• L42-55

Process lifecycle

Before command work, the CLI sets up logging and may start CPU or memory profiling. The root collection path also starts tracing when possible. Profiling stops after the command finishes, while tracing errors do not prevent a support-bundle run.

The command reports errors through process exit status. Workflow results can use distinct statuses for specification problems, warnings, and failures. This lets scripts distinguish a bad request from a completed run that found a problem in the target system.

The root command can check for a newer binary before a direct support-bundle run. The check does not run for child commands, and scheduled jobs turn it off when they invoke the root command.

References: home/…/root.go• L38-70 home/…/root.go• L86-105 home/…/root.go• L176-194 home/…/run.go• L86-100 home/…/daemon.go• L244-267

Output modes

The CLI chooses output for the operator's context. A terminal receives progress and an interactive result view when the root route detects an interactive terminal. A pipe or automation run receives log messages and structured output instead.

Commands that transform a bundle follow the same broad pattern: they print a report by default and can write a named output file when the command supports it. analyze selects YAML or JSON. diff selects a text report or JSON. redact always creates a new archive rather than changing the input archive in place.

References: home/…/run.go• L102-107 home/…/run.go• L160-212 home/…/run.go• L292-303 home/…/analyze.go• L41-64 home/…/diff.go• L651-678 home/…/redact.go• L62-71

Bundle operation commands

The operation commands compose around the support-bundle archive as a shared product artifact. Each command has a narrow purpose, so users can inspect, protect, compare, or deliver a bundle without repeating collection.

Analysis command

support-bundle analyze applies an analyzer specification to an existing bundle. The analyzer specification comes from a local path or URL, while the required --bundle flag identifies the archive to inspect.

The command writes YAML by default or JSON when requested. A hidden compatibility mode can convert results to the support-bundle result shape, which preserves a stable output contract for callers that use the unified CLI after a separate collection step.

References: home/…/analyze.go• L18-75 home/…/analyze.go• L78-115

Redaction command

support-bundle redact protects an existing archive with extra redactor specifications. It reads the archive, applies the selected rules, and writes a second archive to the requested output path or to a time-stamped default name.

This command is useful when the first collection used the default redactors but a sharing policy requires additional rules. The original archive remains available as the source for the redacted copy.

References: home/…/redact.go• L16-29 home/…/redact.go• L34-72

Diff command

support-bundle diff compares two archives as snapshots of a system. It reports added, removed, and changed files, groups changes by broad data area, estimates impact, and can include limited inline text diffs.

The report supports human review and machine use. Text is the default. JSON is available with --format json, and either form can go to standard output or to a file.

References: home/…/diff.go• L77-110 home/…/diff.go• L113-135 home/…/diff.go• L157-300 home/…/diff.go• L651-721

Upload command

support-bundle upload sends an archive to replicated.app or a configured upload domain. It can extract the license ID and application slug from the archive, so a user only needs to supply those values when the bundle does not contain them or when the user must override them.

The root collection command can use the same upload path through --auto-upload. It first keeps the local archive, then attempts the upload and reports a manual upload command if the automatic step fails.

References: home/…/upload.go• L12-60 home/…/run.go• L263-304 home/…/upload.go• L11-58 home/…/upload.go• L61-101

Lint command

support-bundle lint checks one or more v1beta2 or v1beta3 troubleshoot specs before a collection or preflight run. It focuses on syntax, required structure, template use, and common missing content rather than collecting data.

Text is the default report format. JSON supports pipeline use, and automatic fixes are available where the lint workflow can safely apply them. Validation errors use a dedicated non-success exit status.

References: home/…/lint.go• L15-73 home/…/lint.go• L76-99

Scheduled collection

The schedule branch turns a one-time root collection into a recurring local job. It stores the job definition, then a foreground daemon checks the schedule and invokes the support-bundle command with the saved collection options.

Job management

Users create jobs with a name, a five-field cron expression, an optional namespace, and optional auto-discovery or upload behavior. list shows saved jobs and run counts. delete removes a job by name or ID. Creating a job does not start execution; the user must start the daemon.

The job record is the contract between setup and execution. It carries the schedule and the small set of root flags needed to reproduce the requested collection. This keeps recurring work aligned with the same root workflow instead of creating a second collection engine.

References: home/…/cli.go• L32-88 home/…/cli.go• L91-147 home/…/job.go• L13-25 home/…/job.go• L47-88

Scheduler daemon

support-bundle schedule daemon start runs the scheduler in the foreground. It checks enabled jobs every minute, prevents the same job from running twice at once, and records scheduler activity in the user's Troubleshoot directory.

When a job is due, the daemon starts the support-bundle binary directly. It passes the namespace, auto-discovery, and auto-upload choices, and disables binary self-update for predictable scheduled behavior. A successful run updates the job count and last-run time; a failed run stays visible in the scheduler log.

References: home/…/cli.go• L150-171 home/…/daemon.go• L17-25 home/…/daemon.go• L62-101 home/…/daemon.go• L103-129 home/…/daemon.go• L231-325

Product workflow composition

The unified CLI is a coordinator rather than a separate data model. Its value comes from passing one support-bundle artifact between collection, analysis, protection, comparison, and delivery workflows.

Workflow handoffs

The main handoff is the archive. Collection writes the archive and analysis results. Later commands consume that same archive without needing the original cluster connection.

This diagram shows how the CLI composes one-time and follow-up workflows.

flowchart LR
    S[Specs or cluster sources] --> R[support-bundle]
    R --> A[Support-bundle archive]
    R --> AR[Analysis results]
    A --> AN[support-bundle analyze]
    AS[Analyzer spec] --> AN
    A --> RD[support-bundle redact]
    RS[Redactor specs] --> RD
    A --> U[support-bundle upload]
    A --> D[support-bundle diff]
    A2[Earlier archive] --> D
    AN --> OUT[Review or automation output]
    RD --> RA[Redacted archive]
    U --> VP[Vendor analysis service]
    D --> DR[Change report]

The root route can join analysis and upload in one run. Scheduled jobs reuse the root route, so a scheduled archive can enter the same later analysis, redaction, diff, or upload paths as a manually created archive.

References: home/…/run.go• L243-316 home/…/analyze.go• L27-64 home/…/redact.go• L34-72 home/…/diff.go• L113-135 home/…/upload.go• L33-52 home/…/daemon.go• L246-276

Automation boundary

The CLI exposes two useful automation boundaries. A script can call a narrow operation and parse its structured output, or it can call the root route and use its exit status to decide whether collection and analysis completed acceptably.

The archive path is the durable boundary between those choices. It allows collection to run with cluster access while analysis, diff, redaction, and upload run later with only local files and the needed service credentials.

References: home/…/run.go• L283-303 home/…/analyze.go• L49-64 home/…/diff.go• L657-676 home/…/lint.go• L90-99 home/…/root.go• L176-188

Change checklist

When these files or sections are changed, remember to consider these:

  • A root command flag or environment name must remain aligned with the option read by spec loading, auto-discovery, collection, upload, or scheduling.
  • Changes to spec source handling must preserve the merge order and the no-argument fallback to cluster-loaded specs.
  • Changes to the merged support-bundle plan must preserve the --dry-run view and the collector set used by the real run.
  • Changes to archive metadata must remain compatible with automatic license and application detection during upload.
  • Changes to root output text or JSON must be checked against scheduler log parsing and non-interactive callers.
  • Changes to scheduled job fields or flag translation must preserve the daemon's ability to reproduce a root collection run.
  • Changes to command exit statuses must remain meaningful to lint, collection, analysis, and scheduled-job callers.

Important failure modes

TriggerConsequenceGuard
No spec is supplied and the CLI cannot read matching cluster Secrets or ConfigMapsThe root route has no usable collection plan and stops before collectionProvide an explicit spec or grant access to the cluster resources that hold specs.
A source is malformed, missing, or uses an unsupported URI formSpec loading returns a specification error instead of starting the workflowRun support-bundle lint for local specs and check each source before the root run.
The root plan contains no collectors and --auto is not enabledThe CLI refuses to run because it cannot produce diagnostic dataAdd collectors or enable auto-discovery.
Auto-discovery receives an invalid profile or uses --include-images without --autoThe run is rejected before discovery startsUse a supported profile and enable auto-discovery before image collection.
The Kubernetes identity lacks permission for a requested collectorThat collector can be skipped, or the run can fail when collection without permissions is disabledReview RBAC results and choose the intended permission policy.
An interactive run is interrupted while host collection needs elevated accessThe user exits before collection completesRun with the required access or use a non-interactive, permitted collection path.
An upload archive does not contain detectable license or app data and flags are absentAutomatic upload cannot choose an authenticated destinationSupply --license-id and --app-slug.
The schedule daemon is not running or cannot find the support-bundle binarySaved jobs do not create archivesStart the daemon and make the binary available beside the daemon, in the current directory, or on PATH.
A diff input is missing or does not end in .tar.gz or .tgzNo comparison report is producedValidate both archive paths and formats before invoking diff.

Key files

FileWhy to read it
cmd/…/main.goShows the process entry point for the unified CLI.
cmd/…/root.goDefines the command tree, shared setup, root flags, and process status handling.
cmd/…/run.goShows how sources become one collection and analysis workflow.
internal/…/specs.goDefines the supported specification sources and cluster fallback.
cmd/…/auto_discovery.goDefines how auto-discovery augments or replaces the collector plan.
cmd/…/analyze.goDefines analysis of an existing archive.
cmd/…/redact.goDefines creation of a redacted archive from an existing bundle.
cmd/…/diff.goDefines archive comparison and report formats.
cmd/…/upload.goDefines the direct upload command and its input contract.
cmd/…/lint.goDefines pre-run specification validation and its exit status.
pkg/…/cli.goDefines the schedule command hierarchy.
pkg/…/daemon.goShows how scheduled jobs invoke the root support-bundle workflow.
pkg/…/upload.goDefines archive metadata detection and upload delivery.