Application rendering and deployment
Application rendering and deployment turns a fetched release into a versioned application archive that downstream KOTS components can install. It combines release data with application state, user configuration, license data, registry settings, and target details to produce Kubernetes manifests, Helm assets, per-downstream overlays, and the metadata needed by the deployment system.
Release model
The release model separates the source release from the application archive that KOTS prepares for deployment. An Upstream is the fetched release and its release facts. An application archive is the durable working set built from that release and the current installation inputs.
The archive keeps source and derived data in separate roles:
| Archive area | Purpose |
|---|---|
upstream | Source release files and installation data. |
base | Kubernetes resources prepared as the common source for overlays. |
overlays | Midstream and downstream Kustomize changes. |
rendered | Final manifests for each downstream. |
kotsKinds | Rendered KOTS and related control objects used by later operations. |
helm | Helm chart packages and values used by chart-based deployment. |
The release carries identity such as its URI, version label, channel, cursor, release notes, registry domains, and encryption key. It also retains the original license payload when one is supplied, so later chart preparation can use license fields that an older local schema might not know. The application model supplies the application slug and KOTS application specification. These values travel into template context and installation state so that the same release can be rendered for a specific application and installation.
References: pkg/…/types.go• L20-46 pkg/…/types.go• L96-126 pkg/…/kots.go• L85-120
Template context
The template context is the shared view of installation data that release files use when they need values that are known only at install time. It joins configuration values and groups with license, application, version, identity, namespace, and local registry information before resource rendering begins.
The context has two important effects. It resolves KOTS template expressions in ordinary release files and supplies the values used by Helm chart rendering. Configuration defaults are resolved in dependency order, while existing editable values remain the live values for the installation. The same public builder also exposes the established KOTS and Sprig function set, time and proxy helpers, identity values, license fields, and stable function precedence. A chart-specific builder reads packaged chart defaults for HelmValue lookups without executing chart templates or reading customer values. When configuration has not yet been supplied, the pull operation stops after saving the rendered control objects and returns a configuration-needed result instead of creating a deployable archive.
Image helpers connect this context to registry routing. They map images to a local registry when one exists. Otherwise they preserve direct Replicated registry routes and send other images through the application proxy when required. This keeps image references in rendered resources aligned with the registry and credentials available to the installation.
References: pkg/…/templates.go• L10-70 pkg/…/builder.go• L27-76 pkg/…/config_context.go• L79-208 pkg/…/image_context.go• L16-112 pkg/…/helm_value.go• L13-48 pkg/…/pull.go• L348-405
Resource preparation
Resource preparation converts the fetched release into a Kustomize base. The conversion supports direct Helm releases and Replicated releases. It also identifies KOTS control objects so they can be handled as control data rather than as application resources when required.
The base is a logical group of resource files. It can include nested bases for charts that use a separate namespace. The base writer creates Kustomization input, removes duplicate resources by identity, and records files that cannot become valid Kubernetes resources as skipped files. This gives later stages a stable source from which to build each target downstream.
References: pkg/…/render.go• L25-48 pkg/…/base.go• L22-29 pkg/…/base.go• L166-203 pkg/…/write.go• L27-49 pkg/…/write.go• L149-183
Helm assets
Helm assets support chart releases that must remain chart packages for deployment. The system stores the chart archive and its effective values under helm, then uses those inputs to create a rendered chart view for each downstream.
The two supported chart model versions have different archive shapes. Older v1beta1 chart overlays can be rendered through Kustomize and repackaged as chart files. v1beta2 charts keep the upstream chart archive and generated values together, and their rendered output is recorded as all.yaml for review and diff operations.
Chart settings control whether a chart is deployed by Helm or as ordinary rendered resources. Excluded charts do not enter the archive. Conditional and recursive value settings are combined before values are written. Packaged chart defaults include dependency charts and aliases, and dependency versions select the matching defaults. If image rewriting is active, chart images are found and updated as part of the same preparation step.
For airgap releases, Helm values also carry the license data needed by the chart. The pull operation preserves the original license document when it reads a license from an option, a file, or local application state. Chart preparation uses that original payload when available instead of rebuilding it from the local license model, which prevents newer license fields from being lost.
References: pkg/…/helm-v1beta1.go• L20-52 pkg/…/helm-v1beta1.go• L54-170 pkg/…/helm-v1beta2.go• L32-65 pkg/…/helm-v1beta2.go• L68-195 pkg/…/helm-v1beta2.go• L198-306 pkg/…/chart_defaults.go• L21-29 pkg/…/chart_defaults.go• L92-195 pkg/…/helm_value.go• L13-40 pkg/…/pull.go• L41-86 pkg/…/pull.go• L151-182 pkg/…/helm.go• L339-357
Midstream overlays
The midstream overlay is the shared installation layer between the base and each named downstream. It applies installation-wide changes without changing the release base, such as image references, pull secrets, identity resources, object patches, application labels, and disaster recovery labels.
Image handling is part of this layer because the image names in manifests must agree with the registry that the installation can reach. The system can copy images, rewrite them to a target registry, or route private images through the Replicated registry proxy. It then creates pull-secret resources and patches objects that refer to those secrets.
The midstream keeps existing user changes when an archive is rendered again. Its generated entries are merged with existing Kustomization resources, patches, transformers, and annotations rather than replacing user-owned entries without intent.
References: pkg/…/midstream.go• L12-50 pkg/…/write.go• L58-196 pkg/…/write.go• L199-288 pkg/…/write.go• L311-345
Downstream overlays
A downstream is a named target view of the application. It provides the final Kustomize entry point for one installation target while preserving the shared midstream as its base.
For every requested downstream, the pull operation creates a Kustomization that points to the common midstream. Helm bases receive matching downstream entries below the chart path. Existing downstream Kustomization files are not overwritten because they represent user-created content. This lets target-specific changes remain in place while new release content flows through the shared base.
The relationship between release input, shared changes, and final target output is:
flowchart LR
R[Fetched release] --> B[Application base]
B --> M[Midstream overlay]
M --> D[Named downstream]
D --> K[Rendered manifests]
B --> H[Helm assets]
H --> D
References: pkg/…/downstream.go• L8-26 pkg/…/write.go• L12-51 pkg/…/pull.go• L605-752
Rendered manifests
Rendered manifests are the concrete output for a downstream after Kustomize and Helm processing. They exist so deployment, review, diff, and later archive reads use the same target-specific result instead of rebuilding it from changing inputs.
The rendering stage clears old rendered output, builds each downstream, splits the result into separate YAML files, and stores it below rendered/<downstream>. It also stores rendered v1beta1 chart files and v1beta2 Helm output in their chart-specific areas. Helm asset directories are kept separate because Helm installation handles them outside the ordinary Kustomize manifest set.
Rendered KOTS objects are written to kotsKinds. Troubleshoot preflights found inside rendered Helm output are merged into the shared rendered control data. This merge keeps the control data needed for later checks, including the warning state for troubleshoot content that KOTS cannot run. The installation object is refreshed after rendering so its saved state matches the archive that deployment will use.
References: pkg/…/app.go• L22-92 pkg/…/app.go• L105-191 pkg/…/rendered.go• L12-48 pkg/…/kots.go• L664-678 pkg/…/pull.go• L615-658
Deployment archive
The deployment archive is the packaged handoff from rendering to downstream deployment and storage. It includes the upstream release and any available base, overlay, rendered, KOTS-kind, Helm, and skipped-file data. The archive can therefore serve both as the deploy input and as a record of what was prepared for a release.
The archive is created only after the release has been fetched, its resources have been rendered, and its downstream outputs have been written. Older archives may lack rendered data. Read paths detect this case and rebuild the needed output from the base and overlays, which preserves compatibility while newer archives avoid that extra work.
References: pkg/…/app.go• L273-331 pkg/…/archive.go• L10-20 pkg/…/app.go• L105-191 pkg/…/helm-v1beta1.go• L20-51
Pull operation
The pull operation is the end-to-end release preparation flow. It accepts a release source and installation inputs, validates the available license and airgap data, fetches the release, then creates the archive that deployment consumes.
When the system processes a pull request, it follows this sequence:
- It loads local license, configuration, installation, and identity state when present. It keeps the original license bytes so downstream chart preparation can preserve the complete license document.
- It verifies license data and validates an airgap bundle when the installation is offline.
- It fetches and writes the upstream release.
- It renders KOTS control objects and checks whether user configuration is required.
- It creates the base and writes the common and chart-specific midstreams.
- It writes each requested downstream and prepares Helm assets and image handling.
- It renders concrete manifests and saves the current KOTS control objects. Rendered troubleshoot preflights are merged into that control data before it is saved.
- It returns the application archive path for deployment or later storage.
This flow links the acquisition stage described in Upstream release acquisition to the delivery process described in Application delivery. A missing required configuration ends the flow before the deployable archive is returned. A successful flow returns the application directory under the configured root.
References: pkg/…/pull.go• L115-147 pkg/…/pull.go• L151-244 pkg/…/pull.go• L246-302 pkg/…/pull.go• L348-405 pkg/…/pull.go• L451-607 pkg/…/pull.go• L615-658 pkg/…/pull.go• L898-954
Update checks
An update check asks the upstream release service for later versions without building a deployment archive. It carries the current cursor and channel state so the service can compare the installed release with later releases while preserving channel-change behavior.
The pull-facing update check also passes optional Helm repository, license, reporting, and last-check data to the upstream layer. The upstream layer accepts URL-based release sources and currently routes the supported replicated scheme to the release service. It returns a list of available versions or a wrapped error when the lookup fails.
References: pkg/…/peek.go• L16-62 pkg/…/peek.go• L12-25
Application metadata
Application metadata gives the admin system a small application description without requiring it to inspect the full release archive. For licensed Replicated releases, metadata can be pulled from the release service. For airgap releases, it is read from the application archive and includes the KOTS application manifest and branding.
The deployment system stores this metadata in the kotsadm-application-metadata ConfigMap. The ConfigMap keeps the application manifest with the source URI so the admin components can identify and present the application that the archive represents.
References: pkg/…/pull.go• L92-113 pkg/…/pull.go• L805-847 pkg/…/application_metadata.go• L17-43 pkg/…/application_metadata_objects.go• L9-29
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to archive directory names or inclusion rules must stay aligned with archive readers and the rendered-content handlers.
- Changes to Helm chart model fields must preserve the link between chart declarations, chart packages, values files, rendered chart output, and Helm deployment checks.
- Changes to template context inputs or function precedence must be checked against both normal resource rendering and Helm values rendering.
- Changes to packaged chart default handling must preserve dependency aliases, version selection, null overrides, and deterministic ambiguity errors.
- Changes to license loading must preserve both the parsed license view and the original license payload used by airgap Helm values.
- Changes to image rewrite or pull-secret behavior must keep manifest image references, copied images, registry credentials, and generated secret patches consistent.
- Changes to downstream generation must preserve user-created downstream Kustomization files and the relative link from downstream to midstream.
- Changes to rendered KOTS objects or troubleshoot preflight merging must preserve the installation state saved after rendering and the control objects loaded by later deployment steps.
- Changes to update-check inputs or supported upstream schemes must preserve the handoff between the pull-facing update check and the upstream release service.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Required configuration is absent | The pull stops with a configuration-needed result and does not return a deployable archive. | Render control objects first and handle the configuration-needed result before deployment. |
| License verification fails | The release cannot be used, and airgap input can be rejected as belonging to another application. | Verify the license and compare airgap metadata before extracting and fetching the release. |
| Kustomize or Helm rendering fails | No complete downstream manifest set is available for deployment. | Treat rendering errors as pull failures and inspect the source base, overlay, chart, or values input. |
| A chart changes its deployment method across an update | The update is rejected because ownership and upgrade behavior may not be safe. | Keep the method stable or set the required Helm ownership flag for the supported migration. |
| A downstream Kustomization already exists | Generated downstream content is not replaced. | Treat the existing file as user-owned and make intentional downstream changes there. |
| Image rewriting and credential generation disagree | Pods can reference images that the target registry or pull secret cannot serve. | Process the same image set for copying, rewriting, and pull-secret patch creation. |
| An archive entry escapes its extraction directory | Archive extraction could write outside the target directory. | Use safe archive paths during extraction. |
| An update check uses an unsupported source or the release service fails | No update list is returned to the caller. | Use a supported URL scheme and handle the wrapped lookup error before acting on update results. |
| The original license payload is not preserved for an airgap chart | Helm values can omit license fields that the local parsed license model does not represent. | Carry the raw license bytes from pull inputs into the upstream release and prefer them when building chart values. |
| A chart archive is malformed or its packaged defaults conflict | Chart template expansion fails before chart-specific rendering can proceed. | Validate the chart archive and dependency metadata before using HelmValue. |
| A routed image lacks a required registry domain or application slug | Image template expansion fails instead of producing a usable target reference. | Supply the installation registry route and application identity before rendering image helpers. |
| Rendered troubleshoot preflights are not merged into control data | Later preflight checks can miss chart-provided checks or their unsupported-content warning. | Merge rendered preflights through the shared KOTS control-object path before saving kotsKinds. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/pull.go | Shows the complete pull sequence from release fetch through archive output, including license input handling and rendered preflight collection. |
| pkg/…/peek.go | Shows the pull-facing update-check boundary and the state passed to release lookup. |
| pkg/…/peek.go | Shows how update checks select a supported upstream source. |
| pkg/…/types.go | Defines the release model, original license payload, and main archive area paths. |
| pkg/…/kots.go | Defines the application control-object model and its archive loading, saving, and preflight merge rules. |
| pkg/…/render.go | Shows how release types enter resource preparation. |
| pkg/…/write.go | Explains how the common base becomes Kustomize input. |
| pkg/…/builder.go | Shows how shared template contexts become the public rendering contract. |
| pkg/…/config_context.go | Shows how configuration state and installation registry helpers enter templates. |
| pkg/…/helm_value.go | Shows how a chart gets an isolated view of its packaged defaults. |
| pkg/…/chart_defaults.go | Explains how chart and dependency defaults become Helm value lookups. |
| pkg/…/image_context.go | Shows how image names and registry prefixes follow local or Replicated routing. |
| pkg/…/write.go | Shows installation-wide image, secret, patch, and label handling. |
| pkg/…/write.go | Shows how a named target points to the shared midstream. |
| pkg/…/app.go | Shows final manifest rendering and application archive creation. |
| pkg/…/helm-v1beta1.go | Explains compatibility rendering for older Helm chart assets. |
| pkg/…/helm-v1beta2.go | Explains chart package, values, image, and rendered Helm asset handling. |
| pkg/…/rendered.go | Connects application and Helm rendering into one rendered output stage. |
| pkg/…/helm.go | Shows how airgap license data and other release values enter Helm chart values. |
| pkg/…/application_metadata.go | Shows how application metadata reaches the admin deployment environment. |