GitOps Deployment with ArgoCD¶
This document explains how to deploy GrokDevOps using ArgoCD for GitOps-style continuous delivery.
Overview¶
ArgoCD watches a Git repository for changes and automatically syncs the desired state (Helm chart + values) to the Kubernetes cluster. This eliminates manual helm upgrade commands and provides audit trails via Git history.
How ArgoCD Deploys the Chart¶
- ArgoCD monitors the
mainbranch of this repository - When changes are detected in
devops/helm/, ArgoCD renders the Helm template - The rendered manifests are compared against the live cluster state
- Out-of-sync resources are automatically applied (with
selfHeal: true) - Removed resources are pruned (with
prune: true)
Deploying the ArgoCD Application¶
Prerequisites¶
Install ArgoCD on your cluster:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Apply the Application manifest¶
Note: You may see a warning about the
applicationsets.argoproj.ioCRD annotation being too long. This is a known upstream ArgoCD issue and does not affect the Application resource or deployments.
Access the ArgoCD UI¶
kubectl port-forward svc/argocd-server -n argocd 8080:443
# Get initial admin password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Open https://localhost:8080 and log in with admin and the password above.
Environment Structure¶
Each environment uses a different values file:
| Environment | Values File | Branch | Sync Policy |
|---|---|---|---|
| Dev | values-dev.yaml |
main |
Automated |
| Staging | values-staging.yaml |
main |
Automated |
| Production | values-prod.yaml |
main |
Manual approval |
To deploy multiple environments, create one ArgoCD Application per environment, each pointing to the appropriate values file:
# In the Application spec.source.helm section:
helm:
valueFiles:
- ../values-staging.yaml # or values-prod.yaml
Image Promotion Workflow¶
- CI builds a new image and pushes to GHCR with a digest
- Dev: Update
values-dev.yamlwith the new image digest - Staging: Create a PR promoting the digest from dev to
values-staging.yaml - Production: After staging validation, PR promotes digest to
values-prod.yaml
ArgoCD detects the values file change and deploys the new image automatically.
Useful Commands¶
# Check application status
argocd app get grokdevops
# Manually trigger a sync
argocd app sync grokdevops
# View sync history
argocd app history grokdevops
# Rollback to a previous version
argocd app rollback grokdevops <history-id>
Helm Test After Sync¶
ArgoCD can run Helm tests as a post-sync hook:
This runs the test pod defined in templates/tests/test-connection.yaml to verify the service is responding.