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-api-types-and-schemas

Troubleshoot API types and schemas

The Troubleshoot API packages define the configuration contract for support bundles, preflights, collectors, analyzers, and redactors. Versioned Go types describe the objects that the tools load and process. Scheme registration gives those objects stable Kubernetes identities. Generated schemas publish the same contract for Kubernetes resources and external tools.

API version families

The API is grouped under troubleshoot and is split into versioned Go packages at pkg/apis/troubleshoot/v1beta1, pkg/apis/troubleshoot/v1beta2, and pkg/apis/troubleshoot/v1beta3. The version in apiVersion selects the contract that a document must follow.

VersionAPI groupMain role
v1beta1troubleshoot.replicated.comEarlier support-bundle, collector, analyzer, preflight, and redactor objects.
v1beta2troubleshoot.shMain shared contract. It adds host and remote collection flows and wider analyzer coverage.
v1beta3troubleshoot.shNewer support-bundle contract with a focused type set and value references for selected fields.

The first two versions have matching generated JSON schemas and Kubernetes custom resource definitions. The current schema and CRD generation targets in Makefile cover v1beta1 and v1beta2; v1beta3 is available to the runtime client but is not represented by the checked-in schema files listed in schemas/.

Scheme registration

The Kubernetes scheme is the runtime map between a Go object and its group, version, and kind. Loading depends on this map because the decoder must turn an input document into the correct typed object before the rest of the system can use it.

Version identity

Each version package declares one SchemeGroupVersion and one SchemeBuilder. The group and version are therefore part of the type contract rather than a property that callers can change at load time. Each top-level API object registers its object and list form with that builder.

References: pkg/…/register.go• L19-45 pkg/…/register.go• L19-45 pkg/…/register.go• L19-45 pkg/…/supportbundle_types.go• L39-60

Runtime scheme composition

The generated client scheme composes all three version packages. The loader adds core Kubernetes objects for Secret and ConfigMap support, adds the v1beta3 types for decoding, and then uses a universal decoder for input documents. The older pkg/apis aggregator separately collects the v1beta1 and v1beta2 builders, so code that creates its own scheme must use the registration entry point that matches its path.

The loading path accepts recognized Troubleshoot API versions and ignores unrelated YAML documents. A document with an unknown group or version cannot be decoded as a Troubleshoot object, even when its fields look correct.

References: pkg/…/register.go• L31-58 pkg/…/apis.go• L24-29 pkg/…/addtoscheme_troubleshoot_v1beta1.go• L20-26 pkg/…/addtoscheme_troubleshoot_v1beta2.go• L20-26 pkg/…/loader.go• L23-30 pkg/…/loader.go• L171-237

Shared specification types

The top-level objects provide the document envelope. Their spec fields connect the product flows to shared specification types that describe collection work, analysis rules, redaction rules, and result delivery.

Top-level resources

The top-level resource is selected by kind. A support bundle joins collection and analysis, a preflight describes checks for a target environment, and separate collector, analyzer, and redactor objects allow those parts to be supplied on their own. In v1beta2, host and remote resources make host checks and remote host collection first-class parts of the contract.

Resource familyConfiguration relationship
SupportBundleHolds collectors, host collectors, analyzers, host analyzers, and post-collection actions.
PreflightHolds collectors, remote collectors, and analyzers for an environment check.
Collector and HostCollectorHold reusable cluster or host collection definitions.
AnalyzerHolds rules that turn collected data into outcomes.
RedactorHolds rules that remove selected values from collected data.
RemoteCollectorDescribes host checks that run through a remote execution path.

The v1beta1 envelope is smaller. It does not include the v1beta2 host and remote fields in SupportBundleSpec or the corresponding top-level resource families.

References: pkg/…/supportbundle_types.go• L23-59 pkg/…/preflight_types.go• L23-60 pkg/…/collector_types.go• L34-70 pkg/…/analyzer_types.go• L23-56 pkg/…/redact_types.go• L23-56 pkg/…/supportbundle_types.go• L23-64 pkg/…/preflight_types.go• L23-62 pkg/…/hostpreflight_types.go• L23-59

Collection and analysis shapes

Collection and analysis use shared definitions so the same kind of work can appear inside a support bundle or in a standalone resource. A collection definition describes a source of data, such as Kubernetes resources, logs, an HTTP endpoint, a database, a host path, or a remote host check. An analysis definition points to collected data and declares pass, warn, or fail outcomes.

The v1beta2 types also carry common metadata. Collector entries can have a name and an exclusion value. Analyzer entries can have a check name, exclusion and strictness values, and annotations. This common shape lets callers identify and control entries without knowing every collector or analyzer variant.

References: pkg/…/collector_shared.go• L14-18 pkg/…/collector_shared.go• L337-371 pkg/…/analyzer_shared.go• L238-243 pkg/…/analyzer_shared.go• L283-322 pkg/…/host_collector_shared.go• L7-10 pkg/…/host_collector_shared.go• L248-279 pkg/…/hostanalyzer_shared.go• L162-190 pkg/…/remote_collector_shared.go• L10-14 pkg/…/remote_collector_shared.go• L158-178

Value references

StringOrValueFrom defines a value that can be written as a literal or read from a Kubernetes Secret or ConfigMap. In v1beta3, this shape is used for selected database and TLS values. A missing namespace uses the support-bundle namespace, and an optional reference can resolve to an empty value when its source is absent.

The v1beta3 conversion path resolves these references before it produces a v1beta2 support-bundle specification. This keeps the execution model compatible with v1beta2 while allowing the newer input contract to keep sensitive values outside the main document.

References: pkg/…/string_or_valuefrom.go• L3-64 pkg/…/collector_shared.go• L14-39 pkg/…/converter.go• L11-39 pkg/…/converter.go• L97-169

Generated schema contract

The generated schemas are published views of the Go API contract. They describe the JSON form of each resource, including field names, scalar types, arrays, nested objects, and fields that must be present for a particular variant.

Schema generation

Schema generation follows the API type definitions rather than a separate hand-written model. controller-gen builds OpenAPI schemas into the Kubernetes CRDs. The schema tool then writes the standalone JSON files under schemas/. The generated deepcopy and client code are part of the same regeneration step because they must stay aligned with the type packages.

The checked-in artifacts are version-specific. For example, schemas/collector-troubleshoot-v1beta1.json describes the older collector shape, while the v1beta2 CRD and JSON schema include host, remote, and expanded collector and analyzer forms.

References: Makefile• L153-177 schemas/collector-troubleshoot-v1beta1.json• L1-477 schemas/supportbundle-troubleshoot-v1beta2.json• L1-20 config/…/troubleshoot.replicated.com_supportbundles.yaml• L1-20 config/…/troubleshoot.sh_supportbundles.yaml• L1-20 pkg/…/zz_generated.deepcopy.go• L1-21

Schema use

A schema failure usually means that the document does not match the selected version's contract. Check the apiVersion group and version first. Then compare the field name and required fields with the matching schema; a field that exists in v1beta2 is not automatically valid in v1beta1.

The schemas do not replace runtime decoding. A document can pass a broad JSON shape check and still fail when the selected scheme lacks its type or when a v1beta3 value reference cannot be resolved. Treat the API package, the registered scheme, and the generated schema as one contract with three views.

References: pkg/…/loader.go• L40-55 pkg/…/loader.go• L228-237 schemas/supportbundle-troubleshoot-v1beta1.json• L1-20 schemas/supportbundle-troubleshoot-v1beta2.json• L1-20 config/…/troubleshoot.sh_supportbundles.yaml• L8-20

API and schema flow

The following flow shows how a versioned Go type becomes a runtime object and a published schema. Both paths must stay aligned for configuration to work in memory and in external validators.

flowchart LR
    Types[Versioned Go API types] --> Registration[Scheme registration]
    Registration --> Decoder[Runtime decoder]
    Decoder --> Object[Typed Troubleshoot object]
    Types --> CRD[OpenAPI schema in CRD]
    CRD --> JSON[Generated JSON schema]
    JSON --> Validator[External validation and tooling]

Change checklist

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

  • A new or renamed top-level type must be registered in its version package and included in the client scheme before loaders can decode it.
  • A change to a group or version must be reflected in apiVersion handling, the matching CRD, and the versioned standalone schema.
  • A shared field change must be checked in every supported version and in any v1beta3-to-v1beta2 conversion path.
  • A new field in an API type requires regeneration of deepcopy code, client code, CRDs, and standalone JSON schemas before the generated artifacts can describe it.
  • A new value-reference field must define its source resolution and its behavior when the source is missing. Otherwise the schema may accept input that runtime conversion cannot use.

Important failure modes

TriggerConsequenceGuard
A document uses troubleshoot.sh/v1beta2 fields with the v1beta1 group or version.The loader selects the wrong contract or ignores the document.Check the full apiVersion and use the matching schema and CRD.
A new API type is not added to the scheme used by the decoder.YAML cannot become the intended typed object.Add the version builder to the active scheme composition.
Go types change without running generation.Client code, CRDs, or JSON schemas describe an older contract.Run the repository generation and schema targets together.
A v1beta3 Secret or ConfigMap reference is used without a Kubernetes client or with a missing required source.Conversion to the v1beta2 execution shape fails.Supply the client and namespace context, or mark the source optional when that behavior is intended.
A v1beta3 feature outside the current conversion set is used as if it were fully supported.The field may not reach the v1beta2 execution path.Check the v1beta3 converter before depending on a new resource or collector family.

Key files

FileWhy to read it
pkg/…/register.goDefines the legacy group and version identity.
pkg/…/register.goDefines the main group and version identity.
pkg/…/register.goShows the newer version identity and registration entry point.
pkg/…/supportbundle_types.goShows the v1beta1 top-level resource envelope.
pkg/…/supportbundle_types.goShows the expanded support-bundle contract.
pkg/…/collector_shared.goShows the shared cluster collection model.
pkg/…/analyzer_shared.goShows the shared analyzer and outcome model.
pkg/…/host_collector_shared.goShows host collection inputs.
pkg/…/remote_collector_shared.goShows remote collection inputs.
pkg/…/string_or_valuefrom.goDefines literal and Kubernetes-object-backed values.
pkg/…/converter.goShows how supported v1beta3 values enter the v1beta2 execution shape.
pkg/…/register.goShows the runtime scheme used by generated clients and the loader.
pkg/…/loader.goShows document filtering, decoding, and version-aware loading.
MakefileDefines code, CRD, and standalone schema generation targets.
schemas/supportbundle-troubleshoot-v1beta2.jsonShows a generated standalone view of the main v1beta2 contract.
config/…/troubleshoot.sh_supportbundles.yamlShows the Kubernetes CRD view of the v1beta2 support-bundle contract.