Introducing a new way to review your PRs.

Read the announcement

replicatedhq / kots

KOTS provides the framework, tools and integrations that enable the delivery and management of 3rd-party Kubernetes applications, a.k.a. Kubernetes Off-The-Shelf (KOTS) Software.

View on GitHub

21 documents · Updated Nov 23, 2026

docs / gitops-synchronization

GitOps synchronization

GitOps synchronization connects an application and its downstream cluster to a Git repository. When GitOps is active, application delivery writes the rendered deployment state to Git so a Git-based delivery process can apply it. The Admin Console checks repository access, records the connection per application and cluster, and reports the resulting commit back to the delivery view. See Delivery integrations for the wider delivery model and Image and air-gap artifacts for related artifact flows.

GitOps delivery model

GitOps changes the source of authority for application updates. The Admin Console still prepares the application release, but the release reaches the downstream environment through a commit rather than through a direct console deployment.

The synchronization boundary is the application and downstream cluster pair. Each pair has a repository target and rules for the branch, repository path, and file layout. A rendered application file represents the version that the Git workflow must deliver.

The flow from an application release to a Git-backed delivery record is:

flowchart LR
    A[Application release] --> B[Rendered deployment state]
    B --> C[Clone target branch]
    C --> D[Write application file]
    D --> E[Create and push commit]
    E --> F[Git-backed delivery process]
    E --> G[Commit link in Admin Console]

Delivery authority

When GitOps is enabled for an application, the Admin Console does not deploy updates directly. It records the Git commit that represents the update, which lets the external Git workflow control when that state reaches the cluster. References: web/…/SetupProvider.jsx• L88-129, web/…/AppGitops.jsx• L181-191, pkg/…/version_store.go• L549-557

Repository connections

A repository connection supplies the Git provider identity and the access needed to clone and push. The system supports hosted and enterprise forms of GitHub, GitLab, and Bitbucket. Enterprise services use a host name, while Bitbucket Server also uses HTTP and SSH port values. References: web/…/constants.js• L3-35, web/…/GitOpsProviderSelector.jsx• L10-17, pkg/…/gitops.go• L37-50

Repository identity

The connection identifies a repository by its provider and repository URI. The UI collects an owner and repository name for hosted providers. Bitbucket Server uses a project and repository pair. These values are converted into the HTTPS form shown to the operator and the SSH form used for Git access. References: web/…/GitOpsRepoDetails.jsx• L33-60, web/…/utilities.js• L224-249, pkg/…/gitops.go• L82-115

Repository access

The Admin Console creates an Ed25519 SSH deploy key for a new repository connection. The operator must add the public key with write access before the connection test or a later update can push a commit. The private key stays in the protected connection state and is not part of the public GitOps status returned to the web client. References: web/…/AppGitops.jsx• L235-256, pkg/…/gitops.go• L543-561, pkg/…/gitops.go• L705-713, pkg/…/gitops.go• L822-842

Synchronization lifecycle

Synchronization has two related stages. Setup proves that the repository can be reached, while release processing turns each new rendered application version into a Git change.

Connection setup

The operator selects a provider and repository, then may select a branch and path. A blank branch means that the repository's default branch is used. The setup stores the application and cluster target before the connection test begins. References: web/…/context.js• L163-182, web/…/GitOpsRepoDetails.jsx• L135-187, pkg/…/gitops.go• L41-67

The connection test clones the repository with the configured deploy key and returns the branch at the repository head. A successful test fills an omitted branch with that default. A failed test stores the last error for the application and cluster so the connection remains visibly unready. References: pkg/…/gitops.go• L106-187, pkg/…/gitops.go• L452-486, pkg/…/gitops.go• L409-449

Release synchronization

When a release is prepared for a downstream cluster, the system renders the application for that cluster and checks the GitOps connection. If the connection is active, it clones the selected branch, writes the application state below the selected path, and pushes a commit with the application version. The commit URL is then stored with the downstream version record. References: pkg/…/gitops.go• L716-728, pkg/…/gitops.go• L731-819, pkg/…/version_store.go• L519-560

The initial connection also brings Git up to date with versions already known to the downstream cluster. It processes the current version first and then the pending versions. This gives the external Git workflow a history that starts from the existing delivery state. References: pkg/…/gitops.go• L190-271

Commit changes

The system targets one application YAML file under the configured path. If the rendered content matches the file already in the repository, it stops without a new commit. This avoids creating Git history for a release that produces no deployment change. References: pkg/…/gitops.go• L765-797

Synchronization state

GitOps state combines shared repository access with per-application delivery settings. This split allows more than one application to use the same repository while keeping each application and cluster on its own branch and path settings.

Shared repository state

The shared connection stores the provider, repository URI, access key pair, and enterprise network details. The per-application record stores the branch, path, file format, action, and last connection error. The web view uses these records to distinguish configuration from a tested connection. References: pkg/…/gitops.go• L117-205, pkg/…/gitops.go• L319-407, web/…/index.ts• L98-111

Connection status

An application is considered connected when its stored last error is empty after a successful repository test. A configured repository without a successful test remains different from an active GitOps connection. This distinction lets the UI ask for repository access before it treats Git as the delivery path. References: pkg/…/gitops.go• L182-200, web/…/context.js• L54-85, web/…/AppGitops.jsx• L204-256

Disable and reset behavior

Disabling GitOps removes the application and cluster mapping. It removes shared repository key data only when no other application uses that repository. A full reset removes the shared GitOps secret and configuration map, which clears all stored connections. References: pkg/…/gitops.go• L69-104, pkg/…/gitops.go• L208-247, pkg/…/gitops.go• L614-630

Change checklist

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

  • Keep provider URI construction aligned with SSH clone URL and provider-specific commit URL rules.
  • Keep the application-cluster configuration key aligned across setup, status lookup, error updates, and disable flows.
  • Keep shared repository key reuse and cleanup safe when several applications point to the same repository.
  • Keep the public deploy key shown by the web flow aligned with the private key used by clone and push operations.
  • Keep the downstream version record's commit URL and GitOps status aligned with the no-change case, where no new commit is created.
  • Keep initial synchronization rules aligned with the supported file format and the order of current versus pending versions.

Important failure modes

TriggerConsequenceGuard
The deploy key is not added with write accessThe connection test or release push fails, so the application cannot use Git as its delivery pathAdd the displayed SSH key to the provider with repository write access before testing the connection
The repository URI does not match the selected provider's expected shapeThe system cannot build a usable SSH clone URLUse the provider-specific repository and enterprise host fields
A connection test failsThe application keeps a stored error and is not treated as connectedCorrect repository access or connection settings, then run the connection test again
GitOps initialization is already runningA second initialization request is rejected and cannot create duplicate historyWait for the existing gitops-init task to finish
Rendered content is unchangedNo new Git commit or commit URL is produced for that updateTreat the existing repository file as the desired state
The same repository is used by multiple applicationsDisabling one application must not remove access needed by the othersThe disable path removes shared keys only after it finds no other application mapping

Key files

FileWhy to read it
pkg/…/gitops.goDefines the repository connection model, clone and push behavior, connection status, key handling, and cleanup rules.
pkg/…/clone.goShows how existing repositories and empty repositories become a checked-out branch for synchronization.
pkg/…/gitops.goConnects API requests to setup, connection testing, initialization, update, disable, and reset behavior.
pkg/…/handlers.goShows the protected API surface for GitOps operations.
pkg/…/version_store.goShows where a delivered application version invokes Git synchronization and stores its commit link.
web/…/context.jsCoordinates provider setup, application selection, repository settings, and web API calls.
web/…/GitOpsRepoDetails.jsxShows the operator-facing branch and path choices and the setup transition.
web/…/AppGitops.jsxShows repository access guidance, connection testing, and the active GitOps state.