Support bundle artifacts and upload
Support bundle artifact handling turns a troubleshooting specification and collected results into a portable .tar.gz archive. It also adds useful metadata, finds licensing details when available, and delivers the archive through a configured endpoint, a direct upload, or a manual handoff. See Support bundle workflows for the full life cycle.
Artifact life cycle
The artifact life cycle connects specification input to a file that an engineer or a remote service can consume. Collection produces the source files. The system then adds analysis and metadata before it packages and delivers the result.
This diagram shows the main path from a specification to a delivered support bundle.
flowchart LR
A[Specification source] --> B[Loaded and normalized spec]
B --> C[Collected results]
C --> D[Metadata and analysis]
D --> E[Tar gzip archive]
E --> F{Delivery choice}
F --> G[Configured upload]
F --> H[Direct application upload]
F --> I[Local archive for manual sharing]
Specification loading and parsing
Specification loading supplies the rules that define what the support bundle should collect and how it should be delivered. Parsing turns that input into one common SupportBundle model so callers can use local, remote, cluster, and OCI sources in the same workflow.
Specification sources
The loader accepts a local file, an HTTP or HTTPS URL, an OCI reference, or a Kubernetes Secret reference. A Secret reference uses the form secret/<namespace>/<name> and reads the support-bundle-spec data entry. A remote specification can also point to an upstream specification through its uri field (pkg/…/load.go• L151-168, pkg/…/load.go• L225-262).
This range of sources lets an application keep the collection plan near its release or in the cluster while still allowing an engineer to run a plan from disk. URL requests use the shared HTTP client and require a successful response before parsing (pkg/…/load.go• L265-297).
References: pkg/…/load.go• L151-168 pkg/…/load.go• L225-262 pkg/…/load.go• L265-297
Specification normalization
The parser converts supported older document forms to the v1beta2 model before decoding them. A Collector document becomes a SupportBundle with collection and after-collection rules. A SupportBundle document keeps its own rules unless its upstream uri loads successfully, in which case the upstream document becomes the active specification (pkg/…/load.go• L43-105).
The parser reads the first document from a multi-document input. If an upstream source cannot be loaded or parsed, it keeps the current support-bundle document instead of stopping the workflow (pkg/…/load.go• L26-40, pkg/…/load.go• L82-102).
References: pkg/…/load.go• L26-40 pkg/…/load.go• L43-105 pkg/…/supportbundle_types.go• L23-33
Bundle artifact assembly
Bundle assembly combines results from cluster and host collection into one named artifact. The process adds system context after collection so the archive can support both diagnosis and later review.
Result set
The result set is the logical file tree of a bundle. Each collected item has a relative path, which allows the same result to be held in memory or written to a temporary directory before packaging (pkg/…/result.go• L19-23, pkg/…/result.go• L94-138).
The full support-bundle run merges cluster and host results. It does not require every collector to succeed before it can run analysis or create an archive. Failed collectors add error records to the bundle, and excluded or permission-limited collectors appear in a skipped-collector manifest. The run reports collector errors after it has made the best available artifact (pkg/…/collect.go• L158-233, pkg/…/supportbundle.go• L140-176, pkg/…/supportbundle.go• L243-266).
Host results can come from the local machine or from temporary collectors placed on cluster nodes. Remote results keep node context in their paths, and the remote collection wait time uses a default that callers can override (pkg/…/collect.go• L299-354, pkg/…/collect.go• L400-554, pkg/…/collect.go• L724-729).
References: pkg/…/result.go• L19-23 pkg/…/result.go• L86-138 pkg/…/collect.go• L158-233 pkg/…/collect.go• L299-354 pkg/…/collect.go• L400-554 pkg/…/supportbundle.go• L140-176 pkg/…/supportbundle.go• L243-266
Artifact enrichment
Enrichment adds context that is not part of the raw collector output. The standard bundle includes the Troubleshoot version, analyzer results, and an execution summary. Optional user metadata is stored as JSON under metadata/user.json (pkg/…/supportbundle.go• L178-197, pkg/…/supportbundle.go• L199-229).
When tokenization is enabled, the run can also report a bundle ID, tokenization statistics, and a separate redaction map. The redaction map links protected values to their replacements, so it needs stronger protection than the archive itself (pkg/…/supportbundle.go• L309-364). Redaction remains a separate concern that is described in Support bundle redaction.
References: pkg/…/supportbundle.go• L178-229 pkg/…/supportbundle.go• L309-364
Archive packaging
The final artifact is a gzip-compressed tar archive. Its entries retain the result tree beneath a support-bundle directory, and symbolic links remain links when the source result uses them (pkg/…/result.go• L309-412).
The archive name is chosen from the requested output path or from a timestamped support-bundle-<time> name. The CLI normally leaves the archive in the current directory. Library callers use the operating system temporary directory unless they provide another path (pkg/…/supportbundle.go• L101-125).
References: pkg/…/result.go• L309-412 pkg/…/supportbundle.go• L101-125 pkg/…/supportbundle.go• L243-245
Archive parsing and loading
Archive parsing gives later operations access to selected files without requiring callers to understand the tar layout. It also accepts both older archives without a top-level directory and newer archives with one.
Selected file access
The archive reader extracts a bundle to a temporary directory, compares normalized relative paths, and returns the contents of requested files. This supports stable lookups even when the archive layout has changed (pkg/…/parse.go• L105-170). Extraction accepts regular files and rejects paths that would leave the temporary directory. Each extracted file has a decompressed size limit (pkg/…/parse.go• L173-242).
Pod detail loading uses this access layer to combine pod definitions with namespace events. It returns the pod definition, related pod events, and log paths for init and regular containers (pkg/…/parse.go• L36-102).
References: pkg/…/parse.go• L36-102 pkg/…/parse.go• L105-170 pkg/…/parse.go• L173-242
Metadata and licensing information
Metadata and licensing information give the archive identity and operational context. The bundle can contain cluster-provided metadata, user-provided metadata, and a normalized license record that upload tools can use.
Cluster metadata
The supportBundleMetadata collector reads the replicated-support-metadata Secret in its configured namespace. It writes the Secret data as JSON to metadata/cluster.json, which gives downstream systems a stable place to find cluster-level context (pkg/…/support_bundle_metadata.go• L15-53).
This collector is optional and follows the normal collector exclusion rules. A missing Secret prevents this collector from producing its result, rather than changing the meaning of unrelated files (pkg/…/support_bundle_metadata.go• L25-40).
References: pkg/…/support_bundle_metadata.go• L15-53 pkg/…/collector_shared.go• L321-324 pkg/…/collector_shared.go• L337-370
License artifact
The cluster resource collection looks for the replicated Secret across the available namespaces. It reads the embedded license document and writes a compact JSON record with licenseID and appSlug to cluster-resources/license.json (pkg/…/cluster_resources.go• L2323-2386, pkg/…/constants.go• L63-65).
This record is the preferred source for upload identity because it carries both values in one artifact. If the record is absent, bundle inspection can search ConfigMap files for license fields and use the ConfigMap filename as a fallback app slug (pkg/…/extract_license.go• L18-22, pkg/…/extract_license.go• L37-115).
References: pkg/…/cluster_resources.go• L2323-2386 pkg/…/constants.go• L63-65 pkg/…/extract_license.go• L18-22 pkg/…/extract_license.go• L37-115
Upload identity detection
Direct upload needs a license ID for authentication and an app slug to select the destination application. The upload path uses explicitly supplied values first. If either value is missing, the uploader reads the archive and uses the license artifact or its ConfigMap fallback (pkg/…/upload.go• L61-86).
The archive is inspected in one pass. A valid cluster-resources/license.json result takes priority over ConfigMap results even when the ConfigMap appears earlier in the tar stream. License values must have the expected alphanumeric form before they are accepted (pkg/…/extract_license.go• L37-115, pkg/…/extract_license.go• L259-274).
References: pkg/…/upload.go• L61-86 pkg/…/extract_license.go• L37-115 pkg/…/extract_license.go• L259-274
Bundle delivery
Delivery moves the completed archive to the next system or leaves it available for a person to share. The specification can request delivery as part of the run, while the CLI can also upload an existing archive later.
Configured delivery
An afterCollection entry can upload the archive to a configured URI or call a remote endpoint after the archive exists. An upload sends the archive with the request method and content type defined by the request. A callback sends no archive body; it only tells the remote service that processing reached the callback stage (pkg/…/collector_types.go• L23-32, pkg/…/aftercollection.go• L21-63, pkg/…/aftercollection.go• L102-125).
An upload can also provide a redaction-report URI. After a successful archive upload, the client sends the redaction list to that URI. The run marks the archive as uploaded only for a successful upload, not for a callback alone (pkg/…/aftercollection.go• L64-99, pkg/…/supportbundle.go• L288-306).
References: pkg/…/collector_types.go• L23-32 pkg/…/aftercollection.go• L21-99 pkg/…/aftercollection.go• L102-125 pkg/…/supportbundle.go• L288-306
Direct application upload
The support-bundle upload command sends an existing archive to the application upload service. It uses https://<domain>/supportbundle/upload/<app-slug> with replicated.app as the default domain. The request carries the license ID as its authorization value and the archive as gzip content (cmd/…/upload.go• L12-59, pkg/…/upload.go• L11-58).
The same upload path can run after a normal collection command when auto-upload is enabled. If auto-upload fails, the command keeps the local archive and prints a manual upload command instead of discarding the artifact (cmd/…/run.go• L263-280).
References: cmd/…/upload.go• L12-59 pkg/…/upload.go• L11-58 cmd/…/run.go• L263-280
Manual delivery
When no upload succeeds, the archive remains on disk and the CLI reports its path. A user can then send it through the Troubleshoot page or run the upload command with explicit identity values when automatic detection is not possible (cmd/…/run.go• L283-294, cmd/…/upload.go• L17-32).
This local path is an intentional delivery mode. It lets an engineer inspect, redact, or move the archive without requiring the collection command to have network access.
References: cmd/…/run.go• L283-294 cmd/…/upload.go• L17-32
Related workflows
- Support bundle workflows describes the complete collection, analysis, redaction, and delivery process.
- Support bundle collection explains how source files enter the result set.
- Support bundle analysis explains how analyzers use the assembled bundle.
- Support bundle redaction explains how sensitive values are changed before delivery.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the archive layout used by packaging aligned with the normalized path lookup used by archive readers.
- Keep the license.json fields aligned between license collection, identity detection, and the application upload contract.
- Keep the metadata paths stable when changing cluster or user metadata so downstream analysis can still find them.
- Keep
afterCollectionupload and callback semantics aligned with theFileUploadedresult so auto-upload does not send duplicates. - Keep the configured content type and redaction-report contract aligned with the receiving upload service.
- Keep specification source rules aligned with the Secret data keys and upstream URI fallback behavior.
- Keep collector error records and skipped-collector entries aligned with the result tree so partial bundles explain missing data.
- Keep remote host collection timeout behavior aligned with callers that rely on the default or provide an override.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A support-bundle archive uses a path layout that the normalized reader does not recognize. | Requested files appear missing even though they are in the archive. | Preserve the supported top-level directory forms when changing archive packaging. |
| The replicated Secret is missing or its license document is malformed. | license.json is not created, so automatic upload may lack a license ID or app slug. | Supply --license-id and --app-slug when bundle identity cannot be collected. |
| A bundle has no valid license record and no usable ConfigMap fallback. | Direct upload stops before it can build the destination request. | Provide the missing identity values explicitly. |
An afterCollection upload receives a non-tar-gzip content type. | The archive is rejected before the request is sent. | Use an empty content-type query or application/tar+gzip for configured uploads. |
| An upload or callback endpoint returns a status at or above 300. | The delivery step fails, and a non-CLI run returns an error. | Check the endpoint and retain the local archive for another delivery attempt. |
| A configured callback is used as if it uploaded the archive. | The run reports no uploaded file even though the callback succeeded. | Use uploadResultsTo when the remote service must receive the archive bytes. |
| An extracted tar entry attempts path traversal or exceeds the per-file limit. | The entry is skipped or cannot be used by archive readers. | Keep archive entries as safe regular files within the bundle tree. |
| Remote host collectors cannot become ready before the configured or default timeout. | Remote collection stops without the host results from the affected run. | Set RemoteHostCollectTimeoutSeconds high enough for the cluster, or use local host collection. |
| A collector fails while other collectors produce results. | The archive may contain partial data and a final collection error. | Read the collector error records and skipped manifest before treating missing files as an archive failure. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/load.go | Defines specification sources, normalization, and upstream fallback. |
| pkg/…/collect.go | Shows how collector results, failure records, skipped entries, and remote host results enter the artifact. |
| pkg/…/supportbundle.go | Connects collection results, enrichment, packaging, and after-collection delivery. |
| pkg/…/result.go | Defines the logical result set and tar-gzip archive creation. |
| pkg/…/parse.go | Defines safe archive extraction and normalized file lookup. |
| pkg/…/support_bundle_metadata.go | Shows how cluster metadata enters the archive. |
| pkg/…/cluster_resources.go | Shows how the license artifact is derived from cluster state. |
| pkg/…/extract_license.go | Defines license and app identity detection from an existing archive. |
| pkg/…/aftercollection.go | Defines configured archive uploads, callbacks, and redaction reports. |
| pkg/…/upload.go | Defines direct application upload and identity precedence. |
| cmd/…/run.go | Shows the user-facing collection result and auto-upload handoff. |
| cmd/…/upload.go | Shows the user-facing upload command and its manual overrides. |