Moving code from dev to production sounds trivial until you try to do it the GitOps way. In a traditional pipeline, your CI system builds an artifact and pushes it through environments. In GitOps, nothing gets pushed. Your cluster pulls desired state from Git, which means promotion isn't about moving a container — it's about moving a declaration. I learned this the hard way when our team first adopted GitOps and tried to treat Git branches like deployment conveyors. We ended up with merge conflicts, untracked hotfixes, and a production cluster that hadn't synced in two days. Getting environment promotion right is what separates a GitOps setup that actually works under pressure from one that collapses the first time you need to roll back at 2 AM.
This article covers how I design and operate promotion workflows that are reliable, auditable, and boring — which is exactly what you want from a Kubernetes Documentation aligned deployment process. We'll look at the core promotion models, how to build a pull-request driven gitops pipeline that scales past three environments, and how to handle the edge cases like drift, failed syncs, and emergency rollbacks without breaking the Git-is-truth contract.
Why Promotion Breaks When Git Becomes the Source of Truth
In my experience, most teams stumble on promotion because they carry over CI/CD mental models into GitOps. In a classic pipeline, promotion is an action: build once, then kubectl apply or helm upgrade the same image to the next environment. In GitOps, promotion is a state change in Git. The only way to get a new version into staging or production is to change the manifest in the environment-specific branch or folder and let your GitOps operator reconcile it. If you try to shortcut this with manual applies, you create drift that the next reconciliation will either overwrite or fight with.
The second shift is that configuration and code now share the same promotion path, but they shouldn't always share the same source. Application code is versioned as container images. Environment-specific configuration — replica counts, resource limits, ingress hosts, feature flags — is versioned as YAML in Git. A proper deployment promotion has to coordinate both without coupling them too tightly. I've found that teams who store fully rendered manifests per environment quickly drown in duplication, while teams who try to share everything end up with fragile templating.
The Immutable Artifact Principle
The rule I enforce on every gitops pipeline I build is simple: never rebuild an image between environments. You build the image once in CI, tag it with a SHA or semver, push it to your registry, and then promote the pointer to that image. If you rebuild for staging and again for production, you haven't promoted — you've created three different artifacts that happen to share a Git commit. This is where image pinning becomes critical. Your Git repo should reference images by digest (myapp@sha256:abc123...) or by immutable tag, not by latest or floating tags. When an image promotion fails in staging, you know the exact same bits won't run in production.
What Happens Without a Promotion Contract
Without an explicit promotion contract, you get what I call copy-paste promotion: someone copies the YAML from dev to staging, edits a few values by hand, and commits. It works until someone forgets to copy a ConfigMap or changes a secret in one environment and not the other. I've audited clusters where dev and prod had diverged so far that no one could confidently say what was running where. The fix isn't more process — it's a promotion mechanism that is automated, traceable, and requires no manual YAML editing.
Branch-per-Environment vs Directory-per-Environment vs Artifact Promotion: Choosing Your Model
There are three dominant patterns for environment promotion in GitOps. Each has real trade-offs, and the right choice depends on your team size, cluster topology, and how strict your audit requirements are. I've run all three in production and none is universally best.
With the branch-per-environment model, you have a dev, staging, and main branch that each represent an environment. Promotion is a merge or cherry-pick from one branch to the next. It feels intuitive if you come from GitFlow, but it gets painful quickly. Drift between branches makes merges messy, history becomes hard to follow, and GitOps controllers like Argo CD or Flux need to track multiple branches per application.
The directory-per-environment model keeps everything on one branch, usually main, with folders like environments/dev, environments/staging, and environments/prod. Promotion is copying or rendering manifests from one folder to the next via a pull request. This is now the most common approach I recommend for teams running on a single repo. History is linear, pull requests give you a natural approval gate, and you only have one branch to protect.
The third pattern, artifact or release promotion, treats the Git repo as a registry for releases. A tool or controller promotes a release artifact — often a Helm chart version or Kustomize image tag — by updating a version pointer file. This is less about copying YAML and more about moving a reference.
| Promotion Model | How Promotion Happens | Strengths | Common Pitfalls |
|---|---|---|---|
| Branch-per-Environment | Merge / cherry-pick between long-lived branches | Clear isolation, familiar to GitFlow teams | Merge conflicts, divergent history, hard to audit across branches |
| Directory-per-Environment | PR that updates manifests in next environment folder | Single source branch, linear history, native PR reviews | Duplication risk if not using overlays, repo can grow large |
| Artifact / Release Tag | Update image tag / chart version pointer in Git | Minimal duplication, immutable and auditable | Requires tooling, obscures diff of what actually changed |
For most intermediate teams starting out, I suggest directory-per-environment with Kustomize or Helm for templating. It gives you the best balance of visibility and automation without needing custom tooling. If you're managing dozens of clusters, the artifact model with ApplicationSets becomes more attractive, which we cover later. If you're still on branch-per-environment, plan your migration — in my experience, it doesn't scale past 4-5 services.
Designing a Pull-Request Driven Promotion Pipeline That Actually Scales
The core of a reliable promotion workflow is that no human or machine writes directly to the target environment folder. Every change goes through a pull request. This gives you three things for free: peer review, automated validation, and an audit trail. I've found that teams who allow direct commits to environments/prod inevitably allow a hotfix that never makes it back to lower environments.
A practical flow looks like this: CI builds an image tagged with the Git SHA, runs tests, and then opens a promotion PR that updates the image reference in environments/dev. Once the GitOps operator syncs and health checks pass, an automated or semi-automated step opens a PR from dev to staging, and then staging to prod. The promotion PR should only change the image digest or chart version, not the underlying manifests.
Automating Promotion PRs Without Custom Operators
You don't need a complex operator to automate promotion PRs. A simple GitHub Actions or GitLab CI job that runs after a successful sync can create the next PR. The key is to use a promotion tool that understands image pinning. For a directory-based setup, I often use a small script or kustomize edit command inside the workflow rather than manual yq edits, to avoid breaking YAML formatting.
# .github/workflows/promote.yaml
name: Promote Image to Staging
on:
workflow_run:
workflows: ["CI Build"]
types: [completed]
jobs:
promote:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PROMOTION_BOT_TOKEN }}
- name: Update image tag in staging overlay
run: |
cd environments/staging/myapp
kustomize edit set image my-registry/myapp=my-registry/myapp:${{ github.sha }}
# Or pin by digest for true immutability
# kustomize edit set image my-registry/myapp=my-registry/myapp@sha256:${{ env.DIGEST }}
- name: Create promotion PR
uses: peter-evans/create-pull-request@v6
with:
branch: promote/myapp-${{ github.sha }}-to-staging
title: "promote(myapp): ${{ github.sha }} to staging"
body: |
Automated promotion from dev.
- Image: my-registry/myapp:${{ github.sha }}
- Source commit: ${{ github.sha }}
- Dev sync status: verified
labels: promotion, staging
commit-message: "promote myapp to staging: ${{ github.sha }}"
Notice the workflow doesn't deploy anything. It just proposes a Git change. Your ArgoCD in Production: Application Sets, Sync Strategies and Multi-Cluster Management controller or Flux instance does the actual deployment by reconciling. This separation is what keeps the pipeline declarative.
Validation Gates Between Environments
Between dev and staging, I typically allow auto-promotion if tests and sync health checks pass. Between staging and production, I always require a manual approval gate. Your PR should be blocked by status checks: does the YAML pass kubeconform or kubeval, does the Helm chart render without errors, does the Kustomize build produce valid output, and are policy checks like OPA or Kyverno satisfied? We run these validations in CI on the promotion PR itself, not after merge. If the generated manifests are invalid, the PR never merges and bad state never reaches the cluster. For more on keeping the cluster honest after promotion, see Drift Detection and Reconciliation: Keeping Clusters in Sync with Git.
Implementing Promotion with Kustomize Overlays and Helm Value Files
Whether you use Kustomize or Helm, the goal is the same: maintain a single base that defines the default deployment, and overlay environment-specific patches. This avoids copying full manifests for every environment and makes diffs in promotion PRs small and reviewable.
With Kustomize, I structure repos like this: base/ holds deployment, service, and configmap definitions with no environment-specific values. Each overlays/dev, overlays/staging, overlays/prod has a kustomization.yaml that references the base and patches what differs — typically image tag, replica count, and resource requests. Promotion then means updating only the image tag in the target overlay's kustomization.yaml. The patch files themselves rarely change during a promotion.
# environments/base/kustomization.yaml
resources:
- deployment.yaml
- service.yaml
- configmap.yaml
images:
- name: my-registry/myapp
newTag: "placeholder" # replaced by overlay
# environments/overlays/prod/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patches:
- path: replica-patch.yaml
target:
kind: Deployment
name: myapp
- path: resources-patch.yaml
images:
- name: my-registry/myapp
newName: my-registry/myapp
digest: sha256:7f8c4c2a9e1b3d5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b
# environments/overlays/prod/replica-patch.yaml
- op: replace
path: /spec/replicas
value: 5
With Helm, the pattern is similar but uses value files. I keep a values.yaml as the base and values-dev.yaml, values-prod.yaml for overrides. A promotion updates the image.tag or image.digest in the environment's value file. If you are choosing between the two templating tools, this comparison helped me decide on several projects: Flux CD for Kubernetes: GitOps Automation with Kustomize and Helm. In practice, both work; Kustomize tends to be simpler for pure manifest patching, while Helm is better if you already package your services as charts.
Handling Secrets During Promotion
Secrets deserve special treatment. Never promote secret values by copying them between environment folders. In my setups, each environment references its own sealed secret or ExternalSecret that pulls from a vault path specific to that environment — for example, vault/prod/myapp vs vault/dev/myapp. That way a promotion PR contains no secret material at all, only a reference. If you haven't solved this yet, read GitOps Secret Management: Sealed Secrets, SOPS and External Secret Operator before you automate promotion, otherwise you will leak prod secrets into lower environments or break your ability to auto-promote securely. The Terraform Documentation has useful patterns for managing external secret stores declaratively if you provision them with infrastructure as code.
Progressive Promotion Strategies and Safe Rollback Mechanics
Not every change should jump straight from staging to production for all users. For risky changes, I've had success combining GitOps promotion with progressive delivery. Instead of promoting to 100% of production, you first promote to a canary slice of production — say 10% of pods or one region — let it bake with automated analysis, and then promote to full production. Argo Rollouts and Flagger both integrate cleanly with a GitOps promotion model because the Rollout resource itself is promoted via Git, while the controller handles the traffic shifting inside the cluster.
The other half of safe promotion is the rollback plan. In GitOps, rollback is just promotion in reverse: you revert the Git commit that changed the image pointer. Because every promotion is a commit, reverting is a single git revert and a PR. No one needs to remember which helm revision was last good or dig through a CI dashboard. I've made it a rule that any manual kubectl rollout undo must be followed within an hour by a Git revert, otherwise drift detection will undo the manual fix on the next sync.
# argocd/applicationset-promotion.yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp-environments
spec:
generators:
- matrix:
generators:
- git:
repoURL: https://github.com/org/gitops-repo
revision: HEAD
directories:
- path: environments/overlays/*
- list:
elements:
- env: dev
autoSync: true
- env: staging
autoSync: true
- env: prod
autoSync: false # requires manual sync / approval
template:
metadata:
name: 'myapp-{{env}}'
spec:
project: default
source:
repoURL: https://github.com/org/gitops-repo
targetRevision: HEAD
path: 'environments/overlays/{{env}}'
destination:
server: https://kubernetes.default.svc
namespace: myapp-{{env}}
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
This ApplicationSet generates one Argo CD Application per environment from the same matrix. Dev and staging auto-sync, while prod requires a manual sync triggered after the promotion PR merges. The retry block prevents a transient error during promotion from leaving the app in a permanent failed state. If a promoted image fails its health checks, Argo CD will mark the sync as degraded and stop, and you haven't touched production beyond the failed sync — you can revert the Git pointer and the previous healthy state is restored. This is where observability around promotions pays off. Tracking who promoted what, when, and whether it succeeded is essential for change velocity metrics, as covered in detail in our guide to GitOps Observability: Tracking Deployments, Rollbacks and Change Velocity.
Dealing with Failed Promotions and Hotfixes
When a promotion fails, resist the urge to fix it directly in the cluster. I've seen that lead to a state where Git says version A, cluster runs version B, and no one knows which is intended. Instead, fix forward in Git: if staging failed because of a bad config patch, fix the patch in the staging overlay, test, and then promote the fix forward. For production hotfixes, we use a dedicated hotfix/ branch that still goes through a PR into prod, but is immediately back-ported to staging and dev after the incident. That keeps the promotion chain consistent and avoids environment skew.
Frequently Asked Questions
Should I use image tags or digests for environment promotion?
Use digests for production and any environment where immutability matters. Tags are mutable — someone can retag an old image as v1.5 and your Git history will lie about what actually ran. Digests guarantee the bytes you tested in staging are exactly what runs in prod. In development you can use tags for convenience, but pin to sha256 before promoting to staging. Most promotion tooling like Kustomize supports digest fields natively.
How do you handle database migrations during a GitOps promotion?
Run migrations as a separate Job or init container that is part of the promoted manifests, but make them idempotent and backwards-compatible. I promote the migration Job alongside the new app version and use a preSync hook in Argo CD or a Helm hook to ensure it runs before the deployment rolls out. Avoid auto-running destructive migrations on promotion — gate them with a manual approval for production and always have a down-migration tested. Never couple a promotion to a migration that can't be rolled back by reverting Git.
Can I fully automate promotion from dev to production?
Technically yes, but I rarely recommend full automation to production. I automate dev to staging after health checks pass, and require manual approval for staging to prod via a pull request review or Argo CD manual sync. Full auto-promotion to prod removes the human check on business logic and hides the decision of when to release. If you have excellent automated tests, progressive delivery, and feature flags, you can auto-promote small services, but keep a clear approval trail.
How do you prevent configuration drift from breaking promotions?
Enable automated reconciliation with self-heal and prune, and alert on drift. Your GitOps controller should continuously compare Git to cluster state and either correct drift automatically or surface it. I also run periodic drift checks in CI that render the expected manifests and compare them to live state. If someone makes a manual kubectl edit, the controller should revert it and log it. A promotion PR that tries to merge on top of drift will often fail validation — fixing drift first keeps promotions clean.