In modern DevOps, GitOps is the practice of managing infrastructure and application deployments through Git repositories. Instead of manually applying changes with kubectl or scripts, the Git repository becomes the single source of truth.
All changes to infrastructure, services, and applications are:
Version-controlled
Auditable
Automatically applied to the target environment
This guide demonstrates a complete GitOps workflow using ArgoCD on Kubernetes, suitable for development, staging, and production environments.
Company Example: A SaaS company runs multiple microservices on Kubernetes. Their challenges:
Multiple environments: dev, staging, production
Frequent application updates: every 2–3 days
Compliance needs: full audit trail of changes
High availability: zero manual downtime
Solution: GitOps workflow with ArgoCD
All Kubernetes manifests live in Git
Developers push changes to the repo → automatically applied via ArgoCD
Rollbacks happen in seconds if a change breaks the system
Linux server (Ubuntu, Debian, RHEL, AlmaLinux, Rocky)
Kubernetes cluster (single-node or multi-node)
kubectl installed
Helm installed
ArgoCD CLI installed (argocd)
Git repository with Kubernetes manifests (or Helm charts)
Verify Kubernetes:
kubectl version --client
Verify Helm:
helm version
Verify ArgoCD CLI:
argocd version
Create namespace:
kubectl create namespace argocd
Install ArgoCD via manifests:
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Verify pods are running:
kubectl get pods -n argocd
Expected Output:
NAME | READY | STATUS |
|---|---|---|
argocd-server | 1/1 | Running |
argocd-repo-server | 1/1 | Running |
argocd-application-controller | 1/1 | Running |
argocd-dex-server | 1/1 | Running |
Why: Each pod serves a purpose:
argocd-server: Web dashboard + API
argocd-repo-server: Connects to Git repositories
application-controller: Syncs Git manifests to cluster
dex-server: Optional OAuth2 authentication
Option 1 – NodePort (Quick Test):
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
kubectl get svc -n argocd argocd-server
Access dashboard via: https://<server-ip>:<nodeport>
Option 2 – Ingress (Production):
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-ingress
namespace: argocd
spec:
rules:
- host: argocd.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
number: 443
Why: Ingress enables SSL termination and centralized access for production environments.
Get the initial password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Login:
argocd login <server-ip-or-hostname> --username admin --password <password> --insecure
Scenario: You have a Git repo with separate folders for environments:
repo/
├─ dev/
│ └─ k8s/
├─ staging/
│ └─ k8s/
└─ production/
└─ k8s/
Create ArgoCD app for dev:
argocd app create my-app-dev \
--repo https://github.com/company/repo.git \
--path dev/k8s \
--dest-server https://kubernetes.default.svc \
--dest-namespace dev \
--sync-policy automated
Explanation:
--path dev/k8s → Only deploy dev manifests
--dest-namespace dev → Isolate dev environment
--sync-policy automated → Auto-apply changes from Git
Force sync manually:
argocd app sync my-app-dev
Check status:
argocd app get my-app-dev
Output Example:
Name: my-app-dev
Project: default
Sync Status: Synced to HEAD
Health Status: Healthy
Why: Ensures the cluster matches Git repository exactly.
Scenario: A recent commit broke your application in dev. Rollback to previous commit:
argocd app rollback my-app-dev 2
2 → Revision number from Git history
Changes applied immediately to Kubernetes
No downtime required
Developers push changes to dev branch
CI pipeline validates manifests
ArgoCD syncs dev environment automatically
QA approves changes → merge to staging branch
ArgoCD applies changes to staging environment
After approval, merge to production → ArgoCD syncs production
Benefit: Full audit trail and compliance. Every environment reflects Git history.
Use SSH keys or personal access tokens for Git repo
Enable RBAC in ArgoCD to control access
Enforce TLS for ArgoCD dashboard
Use automated sync carefully in production
Enable SSO via OAuth2 / LDAP
Netflix: Uses GitOps patterns with ArgoCD to manage microservices across hundreds of clusters.
Red Hat OpenShift: Supports GitOps natively with ArgoCD integration.
Banks / Financial Services: Maintain audit logs and ensure compliance while automating deployments.
Enable ArgoCD Notifications to send Slack/email alerts for sync failures.
Integrate Prometheus & Grafana to monitor:
argocd-metrics -> Prometheus -> Grafana
Create dashboards for deployment success, health, and drift detection.
Immutable Infrastructure: Git is the single source of truth
Automated Deployments: Reduce human error
Audit & Compliance: Track every change
Fast Rollback: Instant recovery from failed deployments
Consistency Across Environments: Dev, staging, and production stay synchronized