GitOps Delivery Across Dev, Staging and Production Clusters

A GitOps design where Git is the source of truth for every cluster: separate app and environment repos, an Argo CD or Flux control plane, ApplicationSets for fleet rollout, promotion by pull request, external secrets and policy checks before and after merge.

Source of truth

  • App repos
  • Environment repo
  • Platform repo

Build and verify

  • CI pipeline
  • Container registry
  • Policy tests

GitOps control plane

  • Argo CD
  • ApplicationSets
  • Promotion

Clusters

  • Dev
  • Staging
  • Production

Secrets and guardrails

  • External secrets
  • SOPS
  • Kyverno / gatekeeper

How the pieces fit together. Read top to bottom.

Each layer builds on the one below it. A reference design; every real environment is adapted to its constraints.

  1. Source of truth

    • App reposcode, Dockerfile, Helm chart
    • Environment repovalues per env and cluster
    • Platform repoadd-ons, policies, namespaces
    • Pull requestsreview, CODEOWNERS, checks
  2. Build and verify

    • CI pipelinetest, build, scan, sign image
    • Container registryimmutable tags or digests
    • Policy testsKyverno CLI / conftest on PRs
    • Image updaterPR with new digest per env
  3. GitOps control plane

    • Argo CD or Fluxreconciles Git to clusters
    • ApplicationSetsgenerate apps per cluster
    • PromotionKargo or PR-based promotion
    • Notificationssync status to chat and PRs
  4. Clusters

    • Devauto-sync on merge
    • Stagingauto-sync, smoke tests
    • Productionsync after approval
    • Progressive rolloutArgo Rollouts / Flagger
  5. Secrets and guardrails

    • External Secretspull from Vault / cloud KMS
    • SOPSencrypted values in Git
    • Kyverno / Gatekeeperadmission policy in cluster
    • Drift detectionalert on out-of-band edits

From change to running system

  1. 1

    Merge application code

    A developer merges to main. CI runs tests, builds the image, scans it, signs it and pushes it to the registry by digest.

  2. 2

    Open a change for dev

    An image updater or the pipeline opens a pull request that changes the image digest in the dev overlay of the environment repo. Policy tests run on the rendered manifests.

  3. 3

    Reconcile to the dev cluster

    After merge, Argo CD or Flux detects the commit and applies it. Health checks and sync status are posted back to the pull request and team chat.

  4. 4

    Promote to staging

    When dev is healthy, the same digest is promoted to staging through a new pull request or a Kargo promotion step. Nothing is rebuilt between environments.

  5. 5

    Approve and roll out to production

    A production change needs CODEOWNERS approval. Argo Rollouts or Flagger shifts traffic in steps and rolls back automatically if error rate or latency checks fail.

  6. 6

    Detect and correct drift

    The controller compares live state to Git continuously. Manual edits are reported and reverted, or flagged for review when self-heal is off for that app.

The choices that matter

  • Separate app and environment repos

    Keeping environment config apart from app code stops a code merge from silently changing production. The cost is one more repo and a promotion step, which is the point.

  • Argo CD or Flux

    Argo CD brings a UI, ApplicationSets and a central hub model. Flux is lighter, runs per cluster and composes well with Helm and Kustomize controllers. Both are CNCF graduated; choose by team workflow, not features alone.

  • Hub-and-spoke versus per-cluster controllers

    A hub gives one view and one RBAC model but needs network reach into every cluster. Per-cluster agents pull from Git and suit restricted networks, at the cost of a less central view.

  • Secrets referenced, not stored

    External Secrets Operator keeps secret values in Vault or a cloud secret manager and puts only references in Git. SOPS is simpler for small teams but key rotation and access need care.

  • Promote digests, never rebuild

    The artifact tested in staging must be the one that runs in production. Promoting an image digest keeps that guarantee and makes rollback a one-line revert.

This design in depth

Repository layout and why it is split this way

GitOps works when every live object in every cluster can be traced to one file in Git. A layout that scales across teams and clusters usually has three kinds of repositories:

RepositoryContainsChanged by
Application reposSource code, Dockerfile, Helm chart or Kustomize base for one serviceThe service team, through normal code review
Environment repoPer-environment and per-cluster values and overlays, including the image digest each environment runsPromotion automation and approvers named in CODEOWNERS
Platform repoCluster add-ons, policies, namespaces, AppProjects, ApplicationSets and cluster registrationThe platform team

Inside the environment repo, a directory per environment and cluster (for example envs/prod/ap-south-1/payments) keeps differences visible in a single diff. Values that never differ live in the base chart; only true differences such as replica counts, resource sizes, endpoints and feature flags live in overlays. When overlays grow large, it usually means configuration belongs in the application instead. Glossary references: Helm, Kustomize, Argo CD and Flux.

Control plane design and access boundaries

With Argo CD in a hub model, the hub runs in a shared-services cluster and holds credentials to each target cluster. ApplicationSets with the cluster generator create one Application per service per cluster, using cluster labels such as environment, region and tier to decide what goes where. A matrix generator combines clusters with service lists so adding a cluster means adding a labeled cluster secret, and every eligible service follows automatically.

Access is scoped through AppProjects: each team's project limits which repositories it can deploy from, which clusters and namespaces it can deploy to and which resource kinds it may create, so a team cannot deploy cluster-wide objects by accident. Argo CD uses SSO through your identity provider, with RBAC roles mapped to groups. Production sync permission is narrower than dev. The hub's credentials to target clusters are the most sensitive part of the design; we use short-lived, scoped credentials where the platform allows, such as EKS access entries for the hub's IAM role, and restrict network paths to cluster API endpoints.

Where the hub cannot reach clusters, for example in restricted networks or across organizations, the pull model fits better: Flux in each cluster, or an Argo CD agent architecture, pulls from Git and reports status back, and no central system holds cluster credentials.

Deployment, ordering and upgrade flow

Within a sync, order matters. Sync waves and hooks in Argo CD (or dependsOn in Flux Kustomizations) make sure CRDs exist before custom resources, namespaces and secrets before workloads, and database migrations run as a pre-sync job before new application pods start. Health checks decide when a wave is complete, including custom health checks for resources Argo CD does not understand by default.

The GitOps controllers themselves are managed by GitOps. The hub's Argo CD installation lives in the platform repo, and upgrades follow the same promotion path: a version bump in a non-production hub, verification that all Applications stay healthy and in sync, then production. Before upgrading, we read release notes for changes to defaults (for example resource tracking methods or diffing behavior), because a default change can mark many Applications out of sync at once. Add-on upgrades across clusters use the same pattern: change the version for dev clusters by label, observe, then widen the selector to staging and production.

Operations runbooks

  • Application stuck out of sync: usually a mutating webhook or controller changing fields after apply. Identify the field in the diff and add a scoped ignore rule, rather than disabling self-heal.
  • Sync failed on a production change: revert the commit in the environment repo; the controller restores the previous state. Investigate in dev, not in production.
  • Emergency hotfix: the fix still goes through Git, using an expedited review path with fewer approvers, so the record stays complete. Direct kubectl edits are reverted by self-heal.
  • Break-glass manual change: pause auto-sync for that Application with an annotation, make the change, record it, then reconcile Git and re-enable sync.
  • Resource stuck deleting: check finalizers and the owning controller before removing a finalizer manually, since removing it can orphan cloud resources such as load balancers or volumes.
  • Hub outage: clusters keep running their last applied state. Restore the hub from its own manifests in Git and re-register clusters from cluster secrets held in your secret manager.

Cost drivers

GitOps tooling itself is light, but some costs grow with scale: the application controller's memory and CPU grow with the number of Applications and resources watched, and repo-server rendering of large Helm charts consumes CPU on every refresh. Sharding the controller across clusters, caching rendered manifests and using webhooks instead of frequent polling keep the hub small. Other drivers are CI minutes for image builds and policy tests, registry storage for images retained by digest, cross-region data transfer when clusters in several regions pull images from one registry (replication helps), and the engineering time spent on promotion reviews, which good automation reduces.

Variants and when to choose them

  • Single repo, small team: one repository with app code and environment folders, Argo CD per cluster. Fine for one or two services; split when teams multiply.
  • Hub-and-spoke Argo CD: one view across many clusters, ApplicationSets for fleet rollout. Choose when network reach from the hub is acceptable.
  • Flux per cluster: pull-based and lightweight, good for restricted networks, edge clusters and teams comfortable without a central UI.
  • Promotion tooling: PR-based promotion is simplest; Kargo adds stages, verification and freight tracking when promotion rules become complex.
  • Progressive delivery: add Argo Rollouts or Flagger for services where a bad release is costly, starting with the highest-traffic ones.

Related pages: GitOps, DevOps and CI/CD, platform engineering, the EKS landing zone and secure software supply chain reference architectures.

Questions about this design

Something else? Send us your question and an engineer replies with next steps.

How do we handle database migrations in a GitOps flow?

Migrations run as a Kubernetes Job triggered before the new application version starts, using Argo CD pre-sync hooks or an ordered Flux Kustomization. Migrations should be backward compatible, so the old version keeps working while the new one rolls out, with destructive changes in a later release. If a migration fails, the sync stops before new pods start and the team is alerted.

Can developers still use kubectl?

For reading, yes: logs, describe, port-forward in non-production and debugging access as your policy allows. For changing resources, no, at least in staging and production. Changes go through Git so they are reviewed and recorded. Self-heal reverts manual edits, and RBAC limits write access, with a documented break-glass path for emergencies.

How do we add a new cluster to the fleet?

Create the cluster from your infrastructure code, then register it with the GitOps control plane by adding a cluster secret with labels such as environment and region. ApplicationSets match those labels and install platform add-ons, policies and the right applications automatically, in the order defined by sync waves. The cluster becomes ready through a pull request, not manual setup.

What happens if Git or the GitOps controller is unavailable?

Running workloads are not affected; clusters keep their last applied state. You cannot deploy new changes until Git or the controller is back, which is why both should be treated as critical systems with backups. The controller's own configuration lives in Git, so it can be rebuilt quickly, and Git hosting should have its own recovery plan.

How do we keep secrets out of Git?

The recommended pattern is External Secrets Operator: Git holds only a reference to the secret, and the operator fetches the value from a secret manager such as AWS Secrets Manager, HashiCorp Vault or a cloud key vault. For small setups, SOPS-encrypted files in Git work, but key rotation and access control need careful handling. Plain secrets in Git should be blocked by scanning.

Jump to

↑↓ to move↵ to open