Introduction

At 02:14 during a payment outage, an on-call engineer did the fastest thing available: kubectl set image against the production Deployment, watched error rates fall, and closed the incident. Three weeks later the next routine deploy failed in a way nobody could explain. The image tag in Git pointed at a build that had never run in production, the live Deployment carried a hand-applied resource bump that existed nowhere in version control, and when auditors asked which commit produced the running system, the honest answer was "none of them." The hotfix was correct. The system around it was not.

GitOps best practices exist to make that story impossible. GitOps treats a Git repository as the single source of truth for desired state and runs an agent inside the cluster that continuously pulls that state and reconciles reality toward it. Manual changes stop being invisible: they show up as drift, get reverted or get committed, and every running revision maps back to a commit a human reviewed. This guide covers the four OpenGitOps principles, push versus pull deployment mechanics, repository structure and promotion, working Argo CD and Flux configurations, drift and prune operations, secrets and policy guardrails, rollback discipline, and the failure modes that page people at 02:14.


1. GitOps Best Practices Start With What GitOps Is and Is Not

GitOps is an operating model where Git holds the desired state of a system and an in-cluster agent continuously reconciles the live environment toward that state. It is not merely storing YAML in a repository. The reconciliation loop, drift detection, and audit trail are what separate GitOps from version-controlled manifests applied by hand.

The distinction matters because teams routinely adopt the vocabulary without the mechanism. A repository full of Kubernetes manifests plus a CI job running kubectl apply on merge is version-controlled deployment, and it is a perfectly reasonable practice, but it is not GitOps. Nothing watches the cluster between pipeline runs. If someone edits a live object, scales a Deployment by hand, or a partial apply leaves half the resources updated, the pipeline neither knows nor cares until the next event fires. The repository describes what should exist; nobody enforces that it does.

GitOps closes that gap with three commitments. First, desired state is declarative and complete enough that the agent can rebuild the environment from Git alone. Second, changes flow through Git: a pull request is the deployment mechanism, which gives review, approval, and an audit trail for free. Third, an agent running inside the target environment pulls the desired state and continuously compares it with live state, correcting differences according to policy. The agent's position inside the cluster is not an implementation detail; it is what makes continuous reconciliation and drift correction possible without handing cluster credentials to an external pipeline.

What GitOps is not deserves equal clarity. It is not a replacement for CI: building, testing, scanning, and publishing images still belong in continuous integration, and GitOps begins where CI ends, with a versioned artifact ready to promote. It is not a synonym for Kubernetes, although Kubernetes controllers made the model practical. And it is not magic safety: a bad commit reconciles just as faithfully as a good one, which is why validation, progressive delivery, and rollback discipline carry as much weight as the reconciliation loop itself.


2. GitOps Best Practices: The Four OpenGitOps Principles

The OpenGitOps project defines GitOps with four principles: the system is declarative, desired state is versioned and immutable, approved changes are pulled automatically, and software agents continuously reconcile actual state with desired state. Every credible GitOps best practices checklist is an operational consequence of these four statements.

Declarative means the repository describes the target system, not the steps to reach it. A Deployment manifest says "three replicas of this image with these resources"; it does not say "run this script, then patch that field." Declarative state is what allows an agent to compute a diff at any moment and act on it safely, because applying the same desired state twice converges instead of compounding. Imperative steps hidden in hooks and scripts break that property and are a common source of sync loops that never settle.

Versioned and immutable means every desired state is a commit, and history is never rewritten. Rollback becomes selecting an earlier commit rather than reconstructing a previous configuration from memory, tickets, or terminal scrollback. Immutability also disciplines artifacts: an image tag like latest can point at different bytes tomorrow, so GitOps best practices pin images by digest or by an immutable tag tied to a commit SHA. If the artifact can change under the same name, the repository stops being a truthful record of what ran.

Pulled automatically means the agent inside the environment fetches approved changes rather than an external system pushing them in. Pull keeps cluster credentials inside the cluster boundary, works through network partitions by retrying until the repository is reachable, and makes the agent's view of desired state explicit and inspectable. Continuous reconciliation is the principle that turns the other three into operations: the agent does not sync once and exit, it loops forever, comparing, reporting, and correcting. Drift stops being a forensic discovery and becomes a routine, visible event with a policy attached.

The principles also define what an auditor should be able to ask. Given any running pod, an operator should be able to name the commit that produced its specification, the pull request that approved that commit, and the artifact digest it runs, without consulting chat logs or shell history. If any leg of that chain requires archaeology, one of the four principles is being honored in name only. Teams adopting GitOps best practices should run that audit question as a drill, because it surfaces the quiet exceptions (the manually created namespace, the secret applied from a laptop, the Helm release installed outside the agent) that accumulate into unexplainable environments. The drill is cheap, and the exceptions it finds are exactly the drift sources the reconciliation loop cannot see until they are brought into Git.


3. GitOps Best Practices: Push vs Pull Deployment Mechanics

Push deployment acts only when a pipeline runs; pull deployment watches continuously. A CI push pipeline applies manifests on merge and then goes blind until the next event, while a GitOps pull agent inside the cluster reconciles on a loop, detects drift between runs, and needs no inbound cluster credentials from CI.

The mechanics differ in where trust sits. In a push model, the CI system holds credentials powerful enough to modify production, and every pipeline that can deploy is a path an attacker or a misconfigured job can abuse. The pipeline also owns sequencing: apply order, retries, and partial-failure cleanup live in pipeline scripts, and a run that dies halfway leaves the environment in a state no single system describes. Push is simple and familiar, and for small estates it works, but its failure modes are silent ones.

In a pull model, the agent authenticates outward to Git and to the artifact registry, and the cluster API is only ever contacted from inside the cluster. Reconciliation is level-triggered rather than event-triggered: the agent does not care how the live state diverged, only that it differs from desired state now. That property handles manual edits, failed partial applies, controller mutations, and even whole-node loss uniformly. The cost is a new always-on component to operate and secure, plus a shift in debugging habits: "the pipeline succeeded" stops being the question, and "what does the agent report as the diff" becomes the first diagnostic.

Most mature setups are hybrids with a clean seam. CI builds, tests, scans, and publishes an immutable image, then opens a pull request that updates the image reference in the config repository. Merging that pull request is the deployment approval. The agent does the rest. This keeps CI fast and disposable while GitOps owns the stateful, auditable half of delivery. Teams comparing delivery platforms should note that the seam is tool-independent; our GitHub Actions vs Jenkins comparison covers the CI side, and GitLab CI/CD pipeline architecture shows the same split in a single-vendor stack.


4. GitOps Best Practices for Repository Structure and Promotion

GitOps best practices use directories per environment rather than long-lived branches, keep application code and deployment configuration in separate repositories at scale, promote by pull request between environment directories, and pin images by digest or commit SHA so every environment state is reproducible from Git alone.

Branches per environment feel natural and age badly. A production branch that diverges from main turns promotion into a merge conflict exercise, hides exactly what differs between environments, and makes "what is running in staging" a question about branch archaeology. Directories keep every environment visible in one tree, make promotion a small reviewable diff, and let one commit describe the whole estate. The common layout pairs a base of shared manifests with per-environment overlays, typically rendered with Kustomize or Helm values:

config-repo/
  apps/
    payments/
      base/
        deployment.yaml
        service.yaml
        kustomization.yaml
      overlays/
        staging/
          kustomization.yaml
        production/
          kustomization.yaml
  clusters/
    staging/
      payments.yaml
    production/
      payments.yaml

Separating the config repository from application code repositories is a scaling decision with a clear trigger. While one team ships one service, a single repository is simpler. Once multiple teams deploy to shared clusters, a dedicated config repository gives platform teams ownership of promotion policy, keeps deployment history readable without application noise, and lets CI update image references without write access to source code. The trade-off is cross-repository coordination, which the image-update pull request pattern handles mechanically.

Promotion should move an artifact, not rebuild it. The image that passed staging tests is the image production runs, referenced by the same digest. Rebuilding per environment reintroduces every variable GitOps exists to eliminate: different base layers, different dependency resolution, different bytes under the same tag. Pinning by digest (image: registry.example.com/payments@sha256:...) or by an immutable tag containing the source commit SHA makes the promotion diff a single line that reviewers can actually verify. The same discipline underpins infrastructure work generally; our infrastructure as code best practices guide covers the Terraform side of versioned, reviewable state.

At fleet scale, the app-of-apps pattern organizes this structure: a root application points at a directory of Application or Kustomization definitions, so adding a service or a cluster becomes a pull request against that directory rather than a manual agent configuration step. The pattern keeps bootstrap reproducible, which matters most during disaster recovery, when the goal is to rebuild clusters from Git with the fewest possible hand-executed steps. Guard the root carefully, though. It is the highest-blast-radius object in the system, and changes to it deserve the strictest review, the narrowest CODEOWNERS list, and staging rehearsal, because a bad root commit can reconfigure every application it manages in one reconciliation cycle.


5. GitOps Best Practices With Argo CD: A Production Application

Argo CD implements GitOps best practices through Application resources that bind a Git path to a cluster namespace, with automated sync, prune, and self-heal policies controlling how aggressively drift is corrected. Sync status and health status are separate signals, and treating them as one is the most common Argo CD operating mistake.

A production-grade Application declares its source, destination, and sync policy explicitly:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: payments
  namespace: argocd
spec:
  project: production
  source:
    repoURL: https://git.example.com/platform/config-repo.git
    targetRevision: main
    path: apps/payments/overlays/production
  destination:
    server: https://kubernetes.default.svc
    namespace: payments
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
      - ServerSideApply=true
    retry:
      limit: 5
      backoff:
        duration: 30s
        factor: 2
        maxDuration: 5m

Three policy switches deserve deliberate decisions rather than defaults. prune: true deletes live resources that disappear from Git, which is correct for true GitOps and dangerous during migrations or when another controller owns part of the object graph. selfHeal: true reverts manual changes automatically; without it, Argo CD reports OutOfSync but leaves drift in place, which is the right posture during incident response and the wrong one as a permanent setting. Server-side apply reduces conflicts with controllers that mutate objects, such as autoscalers, by letting the API server arbitrate field ownership.

Sync status answers "does live state match Git," while health status answers "is the workload actually working." An application can be Synced and Degraded (the bad manifest applied perfectly) or OutOfSync and Healthy (a manual hotfix is carrying production). Operators who alert only on sync status miss the first case; operators who alert only on health miss the second. Both signals belong in dashboards and alerts, with health treated as the user-facing truth and sync as the audit truth. For a head-to-head on agent selection, see Argo CD vs Flux.

Ordering inside a sync deserves the same deliberateness. Sync waves let operators sequence resources that depend on each other, such as namespaces and CRDs before the workloads that use them, and hooks cover the narrow cases where a job must run before or after a sync, such as a database migration. Both mechanisms are easy to abuse into an imperative pipeline hiding inside declarative state. Keep waves few and coarse, treat hooks as exceptions with owners and expiry dates, and prefer controller-native ordering (readiness, dependencies, init containers) wherever it exists. A sync that only succeeds because of fragile hook ordering will fail during the first disaster-recovery rebuild, which is the worst moment to discover the dependency.


6. GitOps Best Practices With Flux: GitRepository and Kustomization

Flux implements GitOps best practices as composable controllers: a GitRepository source polls the config repository, and a Kustomization reconciles a path from that source into the cluster on an interval. The model is automation-first, with reconciliation expressed as Kubernetes resources rather than a central application server.

The minimal production pair looks like this:

apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: config-repo
  namespace: flux-system
spec:
  interval: 1m
  url: https://git.example.com/platform/config-repo.git
  ref:
    branch: main
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: payments
  namespace: flux-system
spec:
  interval: 5m
  sourceRef:
    kind: GitRepository
    name: config-repo
  path: ./apps/payments/overlays/production
  prune: true
  targetNamespace: payments
  healthChecks:
    - apiVersion: apps/v1
      kind: Deployment
      name: payments
      namespace: payments
  timeout: 3m

Two intervals govern behavior and are routinely confused. The GitRepository interval controls how often Flux checks for new commits; the Kustomization interval controls how often it reconciles, including drift correction against an unchanged revision. Webhook receivers can collapse the first interval to seconds, but the reconciliation loop remains the safety net when webhooks are missed. prune: true carries the same weight as in Argo CD: resources removed from Git are deleted from the cluster, tracked through the Kustomization's inventory, so renames and path moves must be planned as delete-and-recreate events unless the inventory is handled deliberately.

Flux's controller-per-concern design pays off in multi-tenancy. Sources, Kustomizations, and HelmReleases can be scoped per team namespace with service accounts that bound what each reconciliation may touch, so a compromised or buggy tenant configuration cannot reach across the cluster. The operational price is observability: there is no single application dashboard by default, and teams must build their view from controller metrics, events, and flux get output. That trade, visibility versus composability, is the honest axis of the Argo CD and Flux decision.

Whichever agent a team runs, the reconciliation interval is a product decision disguised as a tuning knob. Short intervals shrink the window between merge and running code, which developers feel as responsiveness, but they also multiply API server load and make every repository incident a cluster-wide event at higher frequency. Long intervals are gentler and slower to correct drift. Webhooks remove most of the tension by triggering reconciliation on change while the interval remains a fallback, and GitOps best practices treat that combination, event-driven speed with loop-driven safety, as the default rather than choosing one mechanism and accepting its blind spot.


7. GitOps Best Practices for Drift Detection, Self-Heal, and Prune

GitOps drift is any difference between live state and Git, and GitOps best practices treat drift as a signal with a policy, not an emergency. Self-heal reverts unauthorized change automatically, prune removes resources deleted from Git, and both need exclusions for fields legitimately mutated by autoscalers and controllers.

Drift has mundane sources. An engineer runs kubectl scale during an incident. A HorizontalPodAutoscaler rewrites replica counts continuously. A certificate controller updates annotations. A partial apply from a dying pipeline leaves three of five resources at the new revision. A GitOps agent sees all of these as the same thing, a diff, and the operating question is which diffs should be reverted instantly, which should be tolerated, and which should page a human because they indicate an incident in progress or a process failure.

Self-heal answers the first category: revert and move on. The failure mode is self-heal fighting legitimate controllers. The classic case is replica count: Git declares three replicas, the HPA scales to nine under load, the agent reverts to three, the HPA scales again, and the application flaps while both systems report success. The fix is to stop declaring fields another controller owns: remove replicas from the manifest when an HPA manages it, or configure the agent to ignore that field path. The same pattern applies to fields mutated by admission webhooks, service mesh injectors, and CRD controllers that write status or defaults back into objects.

Prune is the sharper tool. It makes Git deletions real, which is the point, and it makes Git mistakes real at the same speed. Renaming a resource in Git is a delete plus a create; pruning a PersistentVolumeClaim or a namespace-scoped singleton during a refactor can destroy data or availability. Production posture: enable prune, but gate it with pull request review on deletions, protect stateful resources with explicit safeguards where the platform supports them, and rehearse the rename path in staging. Drift dashboards should separate "reverted automatically" from "waiting on a human," because the second list is where process debt accumulates.

Drift response should be a runbook, not an improvisation. When drift is detected, the first question is whether a human intended it. Intentional emergency changes get committed to Git within the incident window, with the incident ticket referenced in the commit, so the audit trail closes. Unintentional drift gets reverted and then explained: which process touched the object, and does that process need an exclusion, a fix, or a removal? Drift that recurs weekly from the same source is a defect in the platform, not background noise, and it should generate engineering work with the same seriousness as a recurring alert. Teams that treat drift this way find the count trends toward zero; teams that mute it find the count trends toward an audit finding.


8. GitOps Best Practices for Validation and Secrets Before Merge

GitOps best practices validate before merge, because a reconciling agent applies bad commits as faithfully as good ones. Schema checks, policy as code, and rendered diffs run in the pull request, while secrets enter Git only encrypted through SOPS or Sealed Secrets, or not at all through External Secrets.

Validation has three layers, each catching a different class of failure. Schema validation (for example kubeconform against the target Kubernetes version) catches malformed manifests and removed APIs before they reach a cluster. Policy as code with Kyverno or OPA Gatekeeper catches organizational rules: no :latest tags, required resource limits, approved registries, mandatory labels. Rendered diffs catch intent errors: the pull request shows the exact object changes the agent will apply, produced by rendering the overlay before and after the change, so reviewers approve effects rather than source text. A change that passes all three can still be wrong, but it can no longer be accidentally wrong in the common ways.

Secrets are where GitOps designs most often collapse. A plaintext Secret manifest in Git is plaintext forever: base64 is encoding, history is permanent, and every clone is a copy. Three patterns work. SOPS encrypts values in the manifest with a KMS or age key, keeping Git as the transport while decryption happens in the agent's environment. Sealed Secrets encrypts against a controller-held key pair so only the target cluster can decrypt. External Secrets Operator keeps values in a dedicated store and syncs them into the cluster, so Git holds references rather than ciphertext. The choice depends on key management maturity, but the rule does not: no plaintext credentials in the repository, enforced by secret-scanning in CI, not by convention. Our Kubernetes ConfigMaps and Secrets guide covers the runtime side of that boundary, including why native Secrets need encryption at rest regardless of how they arrive.


9. GitOps Best Practices for Rollback and Progressive Delivery

GitOps rollback is a Git operation: revert the offending commit and let the agent reconcile back to the previous desired state. GitOps best practices pair that mechanism with progressive delivery, so most bad changes are stopped by automated analysis before a full rollback is ever needed.

The revert path is simple and auditable:

git log --oneline -5
git revert <bad-commit>
git push
argocd app sync payments        # or wait for the reconcile interval
kubectl rollout status deployment/payments -n payments

Two properties make this safer than imperative rollback. The revert is itself a reviewed, recorded change, so the incident timeline stays inside one system. And the target state is a commit that previously ran, not a reconstruction. The limits are equally concrete. Reverting configuration does not revert data: a migration that dropped a column stays dropped, which is why schema changes need expand-and-contract discipline independent of GitOps. Reverting also does not help when the previous commit was itself the problem's cause, or when the bad state came from drift rather than a commit; in the drift case the fix is committing the correction or letting self-heal restore Git state, then investigating why the manual change happened.

Progressive delivery reduces how often rollback is the answer. Argo Rollouts or Flagger shift traffic in steps, evaluate metrics and error budgets between steps, and abort automatically when analysis fails. Combined with GitOps, the promotion pull request starts a controlled rollout rather than a fleet-wide flip, and the abort path is a revert of a change that only ever reached a fraction of traffic. Our deployment reliability and canary releases guide details the analysis patterns; the GitOps-specific point is that delivery strategy belongs in the same reviewed desired state as everything else.

One rollback nuance separates experienced operators from hopeful ones: revert the smallest change that restores safety, not the largest change that restores symmetry. Reverting an entire promotion pull request also reverts unrelated fixes bundled into it, and under incident pressure that bundling is common. Small, single-purpose promotion commits are what make surgical reverts possible, which is another reason promotion diffs should stay minimal and mechanical. When a revert itself fails to reconcile, resist the urge to hand-edit the cluster into compliance; fix the repository state instead, because every manual correction made during a rollback becomes tomorrow's unexplained drift.


10. GitOps Best Practices Troubleshooting Matrix

Most GitOps incidents reduce to a short list of recurring symptoms: OutOfSync loops, prune deleting live resources, syncs stuck progressing, webhooks that never fire, autoscaler drift, plaintext secrets in history, and applications reporting healthy on the wrong version. The matrix below maps each symptom to its root cause and first diagnostic.

SymptomRoot CauseDiagnosis CommandResolution
Application permanently OutOfSyncSelf-heal fighting a controller-owned field, or a mutating webhook rewriting objects after applyargocd app diff payments or flux diff kustomization paymentsRemove controller-owned fields from Git (for example HPA-managed replicas) or add ignore rules for the mutated paths
Prune deleted a live resourceResource renamed or path moved in Git; prune treated it as a deletionargocd app history payments and git log --stat on the config repoRestore from Git history, then re-apply the rename as an explicit migration; require review on deletion diffs
Sync stuck in ProgressingHealth check never passes: failing probes, pending PVC, or a hook job that cannot completekubectl describe pod -n payments and argocd app get paymentsFix the workload health issue; do not force sync past a truthful health signal
Webhook not triggering syncReceiver misconfigured or unreachable; agent falls back to polling intervalflux get sources git or check Argo CD repo-server logsRepair the webhook, then confirm the poll interval alone meets the change-latency requirement
Drift every time the HPA scalesGit declares replica count that the autoscaler ownskubectl get hpa -n payments and compare with the manifestRemove replicas from the Deployment in Git or ignore the field in the agent
Secret committed in plaintextManifest written with raw values; base64 mistaken for encryptiongit log -p --all -- &#x27;secret&#x27; and run secret scanningRotate the credential immediately, purge history, move to SOPS, Sealed Secrets, or External Secrets
App Healthy but running wrong versionImage tag reused or latest mutated; Git state matches but bytes differkubectl get pod -n payments -o jsonpath=&#x27;{.items[].status.containerStatuses[].imageID}&#x27;Pin images by digest or commit-SHA tag and republish; ban mutable tags in policy
Agent cannot reach GitExpired credentials, rotated SSH key, or network policy blocking egressflux get sources git or argocd repo listRotate the repository credential through the same secrets path as application secrets

The pattern across rows is that GitOps failures are rarely mysterious once the diff is visible. The agent always knows what it wants and what it sees; incidents stretch when teams debug the workload before reading the agent's own report. Make the diff the first command in every runbook, and half of these rows resolve in minutes.


11. GitOps Best Practices Production Checklist

A production GitOps setup is ready when Git alone can rebuild the environment, every change arrives by reviewed pull request, drift is detected and policy-handled, secrets never sit in plaintext, and rollback is a rehearsed revert. The checklist below is the acceptance test, ordered by the failures each item prevents.

Repository and promotion: directories per environment, no long-lived environment branches; images pinned by digest or commit-SHA tag; promotion moves the same artifact between environments by pull request; application code and config repositories separated once multiple teams share clusters. Validation: schema checks against the target Kubernetes version on every pull request; policy as code rejecting mutable tags, missing limits, and unapproved registries; rendered diffs attached to reviews so approvers see effects, not source. Agent operations: self-heal enabled with documented exclusions for controller-owned fields; prune enabled with deletion review and stateful-resource safeguards; sync and health alerted as separate signals; agent credentials scoped per tenant where the platform supports it.

Secrets and recovery: no plaintext credentials in Git, enforced by scanning; one chosen pattern (SOPS, Sealed Secrets, or External Secrets) applied consistently; native Secrets encrypted at rest in etcd; rollback rehearsed as a timed revert exercise, including the data-migration caveat; progressive delivery with automated analysis on user-facing services. The final test is destructive and worth running in staging: delete a namespace, let the agent rebuild it from Git, and measure the time. If the rebuild needs a human with shell history, the repository is not yet the source of truth, whatever the dashboards say.

Finally, measure the system you built. Track time from merge to reconciled, drift events per week by source, percentage of changes arriving through pull requests versus every other path, and rollback duration in drills. These four numbers tell leadership whether GitOps is an operating model or a label. A rising manual-change percentage is the earliest warning that the paved road has become slower than the shortcut, and the correct response is to fix the road (faster reviews, better rendered diffs, fewer sync surprises), not to lecture engineers about process. GitOps best practices survive contact with real teams only when the compliant path is also the easiest path.

Frequently Asked Questions

What is GitOps in simple terms?

GitOps means Git holds the desired state of your system and an agent inside the cluster continuously makes reality match it. You change production by merging a pull request, drift is detected automatically, and rollback is reverting a commit. The repository becomes both the deployment mechanism and the audit record.

What are the four GitOps principles?

The OpenGitOps principles are: the system is declarative, desired state is versioned and immutable, approved changes are pulled automatically by agents, and those agents continuously reconcile actual state with desired state. GitOps best practices such as digest pinning, self-heal, and promotion pull requests are operational consequences of these four principles.

Is GitOps the same as CI/CD?

No. CI builds, tests, and publishes artifacts; GitOps deploys and continuously reconciles them. In a complete pipeline, CI produces an immutable image and opens a pull request updating the config repository, and the GitOps agent performs the deployment. GitOps replaces the deployment half of CD, not continuous integration.

How does GitOps detect configuration drift?

The agent periodically compares live objects with the rendered desired state from Git and reports any difference as drift, typically surfaced as an OutOfSync status. With self-heal enabled, the agent reverts the difference automatically; without it, the drift is reported for a human to resolve by committing or reverting the change.

How do you roll back with GitOps?

Revert the commit that introduced the bad change and push; the agent reconciles the environment back to the previous desired state. Because every state is a commit, rollback targets a configuration that previously ran. Configuration rollback does not undo data migrations, so schema changes still need expand-and-contract discipline.

Argo CD or Flux: which should you choose for GitOps?

Choose Argo CD when operators need a strong UI, application-level visibility, and sync/health dashboards out of the box. Choose Flux when you prefer composable controllers, multi-tenancy through namespaced resources, and automation-first operations. Both are CNCF graduated and implement the same GitOps principles; the difference is operating style.

How do you manage secrets in GitOps?

Never commit plaintext credentials. Encrypt values in Git with SOPS or Sealed Secrets so only the cluster can decrypt them, or keep values in an external store and sync them with External Secrets Operator. Enforce the rule with secret scanning in CI, and encrypt native Secrets at rest in etcd.

Does GitOps work for multiple environments?

Yes, and directories per environment are the standard pattern: shared bases with per-environment overlays in one repository, promotion by pull request moving the same image digest from staging to production. This keeps every environment's state visible in one tree and avoids the divergence and merge pain of environment branches.