Complete guide for setting up and using ArgoCD for GitOps-based deployments.
# Create namespace
kubectl create namespace argocd
# Install ArgoCD
kubectl apply -n argocd -f \
https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml# Port forward
kubectl port-forward svc/argocd-server -n argocd 8080:443
# Get admin password
kubectl -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -dAccess: https://localhost:8080
Username: admin
Password: (from above command)
# Apply application manifests
kubectl apply -f argocd/applications.yamlFile: argocd/applications.yaml
Staging:
name: auraweb-staging
source:
repoURL: https://github.com/your-org/your-repo.git
targetRevision: develop
path: k8s/overlays/development
destination:
namespace: auraweb-devProduction:
name: auraweb-production
source:
targetRevision: main
path: k8s/overlays/production
destination:
namespace: auraweb-prodsyncPolicy:
automated:
prune: true # Delete resources not in Git
selfHeal: true # Auto-correct drift
allowEmpty: false # Prevent empty syncsyncOptions:
- CreateNamespace=true
- PrunePropagationPolicy=foreground
- PruneLast=trueretry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m# macOS
brew install argocd
# Linux
curl -sSL -o /usr/local/bin/argocd \
https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x /usr/local/bin/argocdargocd login localhost:8080 \
--username admin \
--password <password># List applications
argocd app list
# Get application details
argocd app get auraweb-production
# Sync application
argocd app sync auraweb-production
# View sync status
argocd app wait auraweb-production
# Rollback
argocd app rollback auraweb-productionUI:
- Settings → Repositories
- Connect Repo using HTTPS
- Enter credentials
CLI:
argocd repo add https://github.com/your-org/your-repo.git \
--username your-username \
--password your-tokenBest for: Development, Staging
syncPolicy:
automated:
prune: true
selfHeal: trueBest for: Production
syncPolicy:
automated: null # Disable auto-syncSync manually:
argocd app sync auraweb-productionArgoCD monitors:
- Deployments
- StatefulSets
- Services
- Ingress
- PVCs
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"# Install notifications controller
kubectl apply -n argocd -f \
https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/stable/manifests/install.yamlapiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.slack: |
token: $slack-token
trigger.on-deployed: |
- when: app.status.operationState.phase in ['Succeeded']
send: [app-deployed]# List revisions
argocd app history auraweb-production# Rollback to specific revision
argocd app rollback auraweb-production <revision-id>
# Rollback to previous
argocd app rollback auraweb-productionUI: Dashboard shows:
- Sync status
- Health status
- Last sync time
- Deployment history
CLI:
# Watch application
argocd app watch auraweb-production
# Get sync status
argocd app get auraweb-production --refreshCheck logs:
# Application logs
kubectl logs -n argocd deployment/argocd-application-controller
# Sync operation logs
argocd app logs auraweb-productionCauses:
- Manual kubectl changes
- Drift from Git
- Failed sync
Fix:
# Hard refresh
argocd app sync auraweb-production --force
# Prune extra resources
argocd app sync auraweb-production --prunek8s/
├── base/ # Base manifests
└── overlays/
├── development/ # Dev overrides
└── production/ # Prod overrides
✅ Separate apps for dev/staging/prod
✅ Different sync policies per environment
✅ Environment-specific configurations
- ✅ Use SSH keys for private repos
- ✅ Enable RBAC
- ✅ Rotate credentials regularly
- ✅ Use sealed secrets
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: root-app
spec:
source:
path: apps/metadata:
annotations:
argocd.argoproj.io/sync-wave: "0" # Database first
argocd.argoproj.io/sync-wave: "1" # Backend second
argocd.argoproj.io/sync-wave: "2" # Frontend last- name: Trigger ArgoCD Sync
run: |
argocd app sync auraweb-production --prunedeploy:production:
script:
- argocd app sync auraweb-production- Install ArgoCD: Set up in cluster
- Configure repository: Add Git repo
- Deploy applications: Apply manifests
- Test sync: Trigger manual sync
- Enable notifications: Slack/Email
Platform: ArgoCD
Type: GitOps
Status: ✅ Production Ready
Documentation: Complete