Intermediate LevelDocker & Deployment
What is GitOps and how do ArgoCD or Flux synchronize Kubernetes clusters with Git?
❓ Interview Prompt: Explain GitOps principles, declarative infrastructure in Git, pull-based deployment model, and ArgoCD sync reconciliation loop.
GitOps is a deployment methodology where Git is the single source of truth for the desired state of all infrastructure and applications.
GitOps Principles (Weaveworks):
1
Declarative: All desired state is described declaratively (Kubernetes YAML, Helm charts).
2
Versioned & Immutable: Desired state stored in Git — every change has a commit hash.
3
Pulled Automatically: Software agents (ArgoCD, Flux) pull and apply changes — not pushed from CI.
4
Continuously Reconciled: Agents continuously compare Git state vs. cluster state and correct drift.
Why Pull-Based (not Push-Based):
•
No CI/CD pipeline needs Kubernetes cluster credentials.
•
The cluster pulls from Git — much lower blast radius if CI is compromised.
•
Automatic drift detection — if someone manually changes a resource, ArgoCD reverts it.
ArgoCD:
•
Runs inside the Kubernetes cluster as a set of controllers.
•
Watches Git repos and continuously syncs the cluster to match.
•
Provides a rich UI for visualizing application state, sync status, and deployment history.
•
Supports Helm, Kustomize, plain YAML, and Jsonnet.
Flux:
•
Kubernetes-native GitOps toolkit (CNCF project).
•
More CLI-oriented than ArgoCD.
•
Native multi-tenant support via
GitRepository + Kustomization CRDs.Code Implementation Example
yaml
# ArgoCD Application — sync cluster with Git repo
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-api
namespace: argocd
spec:
project: default
# Source: Git repository containing K8s manifests
source:
repoURL: https://github.com/myorg/k8s-configs
targetRevision: main # track main branch
path: apps/my-api/production # path within repo
# Destination: target cluster and namespace
destination:
server: https://kubernetes.default.svc # same cluster
namespace: production
# Sync policy: auto-sync on Git changes
syncPolicy:
automated:
prune: true # delete resources removed from Git
selfHeal: true # revert manual cluster changes (drift)
syncOptions:
- CreateNamespace=true💡ArgoCD Application: auto-sync cluster to Git main branch — prune deleted resources, self-heal manual drift.
🎯 Interview Key Takeaway
GitOps makes Git the single source of truth. ArgoCD continuously reconciles cluster state to match Git — auto-reverts manual drift, no CI pipeline needs cluster credentials.
#GitOps#ArgoCD#Flux#Kubernetes#Continuous Deployment#Intermediate
Back to all Docker & Deployment Questions→