GitOps is a paradigm that applies Git workflows to infrastructure and application deployments. It uses Git as the single source of truth for declarative infrastructure and applications.
- Declarative: The entire system is described declaratively
- Versioned: The canonical desired system state is versioned in Git
- Automated: Approved changes are automatically applied to the system
- Observable: The system provides feedback on its actual state
graph LR
A[Developer] --> B[Git Repository]
B --> C[GitOps Controller]
C --> D[Kubernetes Cluster]
D --> E[Monitoring]
E --> C
| Feature | ArgoCD | Flux v2 | Jenkins X | Spinnaker |
|---|---|---|---|---|
| Kubernetes Native | ✅ | ✅ | ✅ | ❌ |
| Multi-Cluster | ✅ | ✅ | ✅ | ✅ |
| UI | ✅ | ❌ | ✅ | ✅ |
| Helm Support | ✅ | ✅ | ✅ | ✅ |
| Kustomize | ✅ | ✅ | ✅ | ❌ |
| Policy Engine | ❌ | ✅ | ❌ | ✅ |
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlSee argocd/example-app.yaml for a complete example.
- App of Apps Pattern: Manage multiple applications
- Sealed Secrets: Encrypt secrets in Git
- Progressive Delivery: Use Argo Rollouts
- Multi-Tenancy: Separate projects and RBAC
flux bootstrap github \
--owner=$GITHUB_USER \
--repository=$GITHUB_REPO \
--branch=main \
--path=./clusters/productionSee flux/example-source.yaml for repository setup.
- Source Controller: Manages Git/Helm repositories
- Kustomize Controller: Applies manifests
- Helm Controller: Manages Helm releases
- Notification Controller: Alerts and webhooks
GitOps directly improves DORA metrics:
- Deployment Frequency: Automated deployments via Git commits
- Lead Time: Reduced manual steps
- MTTR: Quick rollbacks via Git revert
- Change Failure Rate: Preview environments and automated testing
# Annotation for tracking deployments
metadata:
annotations:
dora.metrics/deployment-id: "deploy-123"
dora.metrics/commit-sha: "abc123"
dora.metrics/timestamp: "2024-01-20T10:30:00Z"- Least Privilege: GitOps controllers with minimal permissions
- Secrets Management: Use Sealed Secrets or SOPS
- Policy Enforcement: OPA Gatekeeper or Kyverno
- Audit Logging: Track all changes via Git
.
├── environments/
│ ├── dev/
│ │ ├── kustomization.yaml
│ │ └── patches/
│ ├── staging/
│ │ ├── kustomization.yaml
│ │ └── patches/
│ └── production/
│ ├── kustomization.yaml
│ └── patches/
├── base/
│ ├── deployment.yaml
│ ├── service.yaml
│ └── kustomization.yaml
Combine GitOps with progressive delivery for safer deployments:
- Canary Deployments: Gradual traffic shifting
- Blue-Green: Instant rollback capability
- Feature Flags: Application-level controls
- A/B Testing: Data-driven rollouts
Essential metrics for GitOps:
- Sync status and frequency
- Drift detection alerts
- Resource health metrics
- Deployment velocity
Common issues and solutions:
- Sync Failures: Check RBAC and resource quotas
- Drift Detection: Enable auto-sync or investigate manual changes
- Performance: Tune sync intervals and resource limits
- Secrets: Verify encryption and key management