What is GitOps?
· Category: DevOps & CI/CD
Short answer
GitOps is an operational framework that uses Git repositories as the single source of truth for infrastructure and application configurations. Automated agents continuously reconcile the live state with the desired state in Git.
How it works
Developers commit changes to a Git repository. A GitOps tool like ArgoCD or Flux detects the change and applies it to the cluster. Any manual drift is automatically reverted to match the Git state.
Example
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
spec:
source:
repoURL: https://github.com/org/myapp.git
targetRevision: main
path: k8s
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
selfHeal: true
Why it matters
GitOps provides a complete audit trail, simplifies rollbacks, and improves security by eliminating direct cluster access. It unifies the workflows for application and infrastructure changes.
Tips
- Use separate repositories for application code and deployment manifests.
- Enable auto-sync and self-healing for critical environments.
- Require pull request reviews for all GitOps changes.
Common issues
- Large repositories can slow down reconciliation.
- Secrets should not be stored in plain text in Git.
- Conflicting changes from multiple branches require careful management.