ESC
Type to search guides, tutorials, and reference documentation.
Verified by Garnet Grid

GitOps: Infrastructure Delivery

Implement GitOps for infrastructure. Covers Git as single source of truth, ArgoCD, Flux, deployment strategies, drift detection, and GitOps workflow design.

GitOps uses Git as the single source of truth for infrastructure and application deployments. Instead of running kubectl apply manually or clicking through cloud consoles, every change goes through a Git pull request. A GitOps operator (ArgoCD, Flux) watches the repo and automatically reconciles the desired state in Git with the actual state in the cluster.


GitOps Principles

PrincipleWhat It Means
DeclarativeDesired state described as code, not imperative scripts
VersionedEverything in Git — complete history, auditability
AutomatedChanges applied automatically when Git changes
Self-healingDrift detected and corrected to match Git

Push vs Pull Deployment

AspectPush (Traditional CI/CD)Pull (GitOps)
Who deploysCI system pushes to clusterOperator in cluster pulls from Git
CredentialsCI needs cluster credentialsOperator runs inside cluster
Drift detectionNone (deploy and forget)Continuous reconciliation
RollbackRedeploy old versiongit revert
Audit trailCI logsGit history

ArgoCD Architecture

┌──────────┐     ┌──────────────┐     ┌──────────────┐
│ Git Repo │     │   ArgoCD     │     │  Kubernetes  │
│          │◀────│              │────▶│  Cluster     │
│ manifests│     │ • Sync       │     │              │
│ helm     │     │ • Diff       │     │ • Pods       │
│ kustomize│     │ • Health     │     │ • Services   │
│          │     │ • Rollback   │     │ • ConfigMaps │
└──────────┘     └──────────────┘     └──────────────┘

                 ┌─────▼─────┐
                 │ Dashboard  │
                 │ (Sync      │
                 │  status,   │
                 │  health)   │
                 └────────────┘

ArgoCD Application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: order-service
  namespace: argocd
spec:
  project: commerce
  source:
    repoURL: https://github.com/company/k8s-manifests
    targetRevision: main
    path: apps/order-service/overlays/production
  destination:
    server: https://kubernetes.default.svc
    namespace: commerce
  syncPolicy:
    automated:
      prune: true         # Delete resources not in Git
      selfHeal: true       # Fix drift automatically
    syncOptions:
      - CreateNamespace=true
    retry:
      limit: 5
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 3m

Deployment Strategies

StrategyRiskRollback SpeedCost
Rolling updateMedium (gradual)MinutesNo extra resources
Blue-GreenLow (instant switch)Seconds2x resources
CanaryLowest (% traffic)SecondsMinimal extra resources
Feature flagsLowest (code-level)InstantNo extra resources

Repository Structure

k8s-manifests/
├── apps/
│   ├── order-service/
│   │   ├── base/                    # Shared manifests
│   │   │   ├── deployment.yaml
│   │   │   ├── service.yaml
│   │   │   └── kustomization.yaml
│   │   └── overlays/
│   │       ├── development/         # Dev overrides
│   │       ├── staging/             # Staging overrides
│   │       └── production/          # Prod overrides
│   │           ├── kustomization.yaml
│   │           └── patches/
│   │               └── replicas.yaml
│   └── payment-service/
│       └── ...
├── infrastructure/
│   ├── monitoring/
│   ├── ingress/
│   └── cert-manager/
└── argocd/
    ├── projects/
    └── applications/

Anti-Patterns

Anti-PatternProblemFix
Manual kubectl in productionNo audit trail, no rollback, driftAll changes through Git PRs
CI pushes to clusterCI has cluster credentials, no drift detectionGitOps operator pulls from Git
Monorepo for app + configApp changes trigger config deploysSeparate app repo and config repo
No automated syncGitOps without automation is just GitEnable automated sync with self-heal
Secrets in GitCredentials exposed in repositorySealed Secrets, External Secrets, or SOPS

Checklist

  • GitOps operator deployed (ArgoCD or Flux)
  • All manifests in Git (no manual kubectl)
  • Automated sync enabled with self-healing
  • Repository structure: base + environment overlays
  • Secrets managed externally (Sealed Secrets, External Secrets)
  • Deployment strategy: canary or blue-green for critical services
  • Drift detection: alerts on manual cluster changes
  • PR reviews required for production changes
  • Rollback tested: git revert produces clean rollback

:::note[Source] This guide is derived from operational intelligence at Garnet Grid Consulting. For GitOps consulting, visit garnetgrid.com. :::

Jakub Dimitri Rezayev
Jakub Dimitri Rezayev
Founder & Chief Architect • Garnet Grid Consulting

Jakub holds an M.S. in Customer Intelligence & Analytics and a B.S. in Finance & Computer Science from Pace University. With deep expertise spanning D365 F&O, Azure, Power BI, and AI/ML systems, he architects enterprise solutions that bridge legacy systems and modern technology — and has led multi-million dollar ERP implementations for Fortune 500 supply chains.

View Full Profile →