Support bundle collection
Support bundle collection turns application and cluster state into a diagnostic archive. KOTS builds a Troubleshoot specification for the current installation, collects and checks the requested data, stores the archive with its file tree and findings, and serves the result through the Admin Console API. This page is a child of Backup, recovery, and support operations and relates to Snapshots and disaster recovery.
Support bundle specifications
A support bundle specification is a Troubleshoot document that defines the data to collect and the checks to run. KOTS prepares this document from application rules, cluster rules, and built-in rules before collection begins.
Specification sources
Each source has a clear role in the final diagnostic view. This separation lets an application add its own checks without losing platform checks that apply to every Admin Console installation.
| Source | Purpose |
|---|---|
| Vendor specification | Uses the application's SupportBundle definition for application-specific collectors and analyzers. |
| Cluster-specific specification | Adds specifications discovered in the cluster for cluster or platform diagnostics. |
| Default specification | Provides the baseline Admin Console collectors and analyzers for cluster state, service logs, node health, storage, and related checks. |
| kURL specification | Adds kURL platform data when the cluster is a kURL cluster. |
| Dynamic rules | Add data that depends on the running installation, such as application metadata, installed application archives, Velero logs, and snapshot-related events. |
The static source files are parsed through dedicated getters. URI-backed sources can therefore follow their current remote definition when the cluster mode permits it. The built-in default analyzer set is returned as a copy so later changes do not alter the shared source. References: pkg/…/embed.go• L1-39, pkg/…/embed.go• L11-24, pkg/…/defaultspec.yaml• L1-175
Specification assembly
KOTS assembles one usable specification from the sources and then publishes both its parts and its merged form as Kubernetes Secrets. The merged form is the specification used by the normal collection path and by the generated command for an external collection.
The assembly follows these rules:
- The application
SupportBundledefinition takes priority over older separate collector and analyzer definitions. - References in the application specification are resolved before the specification is used. A reference error stops creation of that rendered application specification.
- Cluster specifications are discovered from labeled Secrets and ConfigMaps. KOTS-owned support bundle objects are excluded from that discovery.
- Each discovered specification is prepared and resolved on its own. A malformed or unresolved discovered specification is skipped while other discovered specifications remain usable.
- Collectors and analyzers from all sources are merged and duplicate entries are removed.
- Templates are rendered for the selected application version. Collector image data is then adjusted to match the running Admin Console image and its pull secret.
- Namespace defaults are added for the Admin Console and application namespaces. Existing explicit namespaces remain in control.
- Limited cluster permissions reduce the namespaces that KOTS targets for collection and analysis.
- Redaction specifications are prepared separately for Admin Console settings, application settings, and default rules.
The final result also carries an upload action when an external command must return its archive to the Admin Console. Internal collection disables that action because it receives the archive directly. References: pkg/…/spec.go• L50-148, pkg/…/spec.go• L176-271, pkg/…/spec.go• L274-383, pkg/…/spec.go• L386-500, pkg/…/spec_test.go• L21-51
Collection execution
Collection execution creates a bundle record first and then runs the Troubleshoot engine in the background. The record gives the caller an ID for progress checks while the engine gathers data, creates an archive, and produces analysis.
Collection lifecycle
The lifecycle moves from specification preparation to collection, archive indexing, storage, analysis, and redaction report storage. This diagram shows the main path for a collection started by the Admin Console.
flowchart LR
A[Collect request] --> B[Build specs and redactors]
B --> C[Create running bundle record]
C --> D[Run Troubleshoot collectors]
D --> E[Create file tree]
E --> F[Store archive and tree index]
F --> G[Mark bundle uploaded]
G --> H[Read or create analysis]
H --> I[Store redaction report]
The Admin Console creates a running record and returns an accepted response with the bundle ID. Collection progress updates the record as collectors finish. The record reaches uploaded after the archive is stored. Analysis and redaction data are then saved for later viewing. References: pkg/…/supportbundle.go• L35-69, pkg/…/execute.go• L147-280, pkg/…/types.go• L16-67, pkg/…/troubleshoot.go• L440-462
Collection modes
KOTS supports two collection modes that use the same specification model but have different archive paths.
| Mode | Archive path | Delivery behavior |
|---|---|---|
| Admin Console collection | The Admin Console runs the collection in the cluster. | The archive is stored directly after collection. |
Generated kubectl support-bundle command | A client-side command loads the cluster specification and sends the result back. | The AfterCollection action sends the archive and its redaction report to Admin Console endpoints. |
The generated command installs the support-bundle client and loads the cluster specification. It also passes the Admin Console, application, and default redaction specifications so the external collection uses the same redaction rules as an Admin Console collection. References: pkg/…/supportbundle.go• L100-109, pkg/…/supportbundle_test.go• L14-33
Both modes enable redaction during collection. The collector can continue when a permission error affects one item, so a partial diagnostic result can still be useful. A missing progress update makes a running bundle stale; the store reports it as failed after its short progress timeout. A collection also has a longer overall execution limit. References: pkg/…/execute.go• L35-145, pkg/…/execute.go• L159-200, pkg/…/spec.go• L274-306, pkg/…/supportbundle.go• L100-109
Analysis results
Analysis turns collected data into findings that the Admin Console can show with a severity, message, detail, and optional object link. New bundle formats can include analysis.json in the archive. Older formats do not, so KOTS rebuilds the analyzer set from the current application archive and analyzes the stored archive after upload.
This compatibility path matters during upgrades because the archive and its analysis may have been created by different KOTS versions. The stored analysis is normalized into support bundle insights rather than exposing the raw analyzer result as the primary API model. References: pkg/…/supportbundle.go• L183-227, pkg/…/supportbundle.go• L230-354, pkg/…/supportbundle_store.go• L474-536
File-tree handling
The file tree is a compact view of the archive contents. KOTS builds it after collection and stores it beside the archive so the Admin Console can show the archive structure without unpacking the full bundle for every tree request.
Archive tree
KOTS extracts the compressed archive into a temporary work area and walks its files and directories. It removes the timestamped top-level support bundle directory from displayed paths, then turns the remaining paths into nested nodes with a name and path.
The tree index is stored as JSON. The archive remains the source for file contents, while the tree index supports browsing and lets the API fetch selected files when needed. References: pkg/…/filetree.go• L14-90, pkg/…/filetree.go• L93-130, pkg/…/types.go• L69-77, pkg/…/troubleshoot.go• L138-166
Stored bundle artifacts
The store keeps the archive and its related records as separate artifacts. The bundle record describes identity, status, size, timestamps, and progress. The archive holds collected files. The tree index, analysis, and redaction report support views and later processing.
| Artifact | Role |
|---|---|
| Bundle archive | Provides the complete collected diagnostic data for download or file lookup. |
| Tree index | Describes the archive hierarchy for browsing. |
| Analysis | Holds normalized findings for the bundle summary. |
| Redaction report | Records which values were redacted during collection. |
The archive and compressed metadata use the file store. Bundle state and analysis are kept in Kubernetes Secrets in the Admin Console namespace. This split keeps large archive data out of the state record while keeping status and findings available through the cluster API. References: pkg/…/supportbundle_store.go• L285-400, pkg/…/supportbundle_store.go• L437-471, pkg/…/supportbundle_store.go• L501-627
Server delivery
Server delivery connects a collected archive to the Admin Console API. Authenticated routes let an operator inspect and manage bundles, while two upload routes accept results from the generated external command.
Admin Console API
The API exposes the bundle lifecycle as a small set of operator actions. Read access covers status, findings, archive files, redactions, pod details, and download. Write access starts collection, shares a bundle, and deletes stored data.
| Capability | API behavior |
|---|---|
| Start collection | Returns the bundle ID before background work completes. |
| List or inspect | Returns bundle state and available analysis for an application or bundle. |
| Browse or download | Reads the stored archive to return selected file contents or the complete compressed archive. |
| Share | Sends the bundle to the configured sharing service and records the share time when successful. |
| Delete | Removes the bundle record and its stored archive. |
These operator routes use the support bundle read and write access policies. The upload and redaction routes are separate because the generated kubectl support-bundle command must reach them without an Admin Console session. References: pkg/…/handlers.go• L57-77, pkg/…/troubleshoot.go• L138-215, pkg/…/troubleshoot.go• L277-309, pkg/…/troubleshoot.go• L420-438
External archive upload
An external collection receives its destination from the assembled specification. The destination includes the application ID and a temporary bundle ID. The client sends the compressed archive with PUT, and the server creates the stored bundle and its tree index before it creates or reads analysis.
The redaction report uses a second PUT endpoint. The server stores it as bundle metadata after the archive upload. These routes are intentionally unauthenticated because the generated command calls them directly; the bundle ID and destination in the generated specification bind the returned data to the collection request. References: pkg/…/spec.go• L274-306, pkg/…/handlers.go• L370-384, pkg/…/troubleshoot.go• L464-508, pkg/…/troubleshoot.go• L565-592
Diagnostic artifact migration
Migration keeps support data usable when storage or specification formats change. It covers old database records, old specification objects, and old bundle archives that lack embedded analysis.
Bundle record migration
Older installations stored bundle records and analysis in rqlite. The migration reads those records, converts the analysis and redaction report, writes bundle Secrets and file-store metadata, and then removes the old rqlite rows after the new records are created.
The migration preserves bundle identity, application ownership, status, dates, size, archive tree, and sharing state. It skips creation when the target Secret already exists, which makes a repeated migration safe for records already moved. References: pkg/…/supportbundle_store.go• L38-195
Legacy specification cleanup
Older versions stored the vendor, cluster-specific, and default sub-specifications in ConfigMaps. They also stored rendered redaction specifications there. Current assembly stores these specs in Secrets. Startup cleanup removes only labeled legacy support bundle and redaction-spec ConfigMaps that match their old KOTS naming patterns; it leaves merged specs, redactor backends, unrelated objects, and Secrets unchanged.
This cleanup is idempotent, so it can run during each Admin Console start without changing already migrated specifications. References: pkg/…/migrate.go• L15-76, pkg/…/spec.go• L257-271, pkg/…/migrate_test.go• L16-128
Change checklist
When these files or sections are changed, remember to consider these:
- Update reference preparation, discovered-spec loading, and the collection engine together when Troubleshoot spec versions or reference rules change.
- Keep the specification assembly and generated command together when an upload URL, redaction URL, or collection mode changes.
- Keep the bundle status, progress count, archive upload, and timeout behavior aligned because the API reports one lifecycle record for all of them.
- Preserve the archive path and tree-index contract when changing file-store layout or file browsing behavior.
- Keep both legacy support bundle and redaction-spec cleanup patterns narrower than the current Secret and redactor naming schemes so startup cleanup does not delete current data.
- Keep the embedded analysis.json path and the old-archive analyzer fallback compatible when analyzer output changes.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A discovered specification has an invalid reference or cannot resolve a referenced Secret. | That discovered specification is skipped, while other discovered specifications continue to load. | Each discovered object is prepared and resolved independently. |
| The application support bundle has an invalid reference. | Rendered specification creation stops before collection. | Application references are resolved before the specification is assembled. |
| A collector cannot access a resource because of cluster permissions. | That item is missing from the archive, but the collection can continue with partial data. | The executor enables collection without permissions and records collector progress and errors. |
| A collection stops updating its progress record. | A bundle that still says running is reported as failed after the progress timeout. | The update routine refreshes the record on a ticker and checks the last update time when the bundle is read. |
| The archive cannot be unpacked or indexed. | The bundle is not uploaded because the file tree is required for storage and browsing. | Collection sends a failed progress update before it exits. |
| An external upload succeeds but old-style analysis cannot be rebuilt. | The archive is stored, but the analysis step reports an error and findings may be unavailable. | The code first looks for embedded analysis.json and only uses the fallback for older bundles. |
| A legacy support bundle ConfigMap has the troubleshoot label and an old sub-spec name. | Startup cleanup deletes the old object. | Cleanup limits deletion to labeled ConfigMaps that match the vendor, cluster-specific, or default sub-spec pattern. |
| A legacy redaction-spec ConfigMap has the KOTS Admin Console label and an old redaction-spec name. | Startup cleanup deletes the old rendered redaction specification. | Cleanup limits deletion to matching labeled ConfigMaps and does not delete the redaction backend ConfigMap. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/spec.go | Defines how application, discovered, static, dynamic, and redaction rules become the final support bundle specification. |
| pkg/…/spec_test.go | Shows that invalid discovered references do not block valid specifications and that namespace and duplicate rules stay stable. |
| pkg/…/defaultspec.yaml | Shows the baseline Admin Console collectors and analyzers. |
| pkg/…/kurlspec.yaml | Shows the platform-specific collection and checks added for kURL. |
| pkg/…/execute.go | Shows the collection lifecycle, progress reporting, archive upload, analysis, and redaction stages. |
| pkg/…/filetree.go | Defines how an archive becomes a browsable file tree. |
| pkg/…/supportbundle.go | Connects collection requests, generated external commands, stored bundle creation, and analysis compatibility. |
| pkg/…/supportbundle_test.go | Confirms the generated external command includes cluster-spec loading and all redaction specifications. |
| pkg/…/supportbundle_store.go | Defines bundle state, archive and metadata storage, retrieval, and the rqlite migration. |
| pkg/…/troubleshoot.go | Shows the API behavior for collection, upload, download, file access, analysis, and redactions. |
| pkg/…/handlers.go | Shows the authenticated operator routes and unauthenticated external upload routes. |
| pkg/…/migrate.go | Defines cleanup of legacy support bundle and redaction-spec ConfigMaps. |