Skip to content

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

  1. ArgoCD monitors the main branch of this repository
  2. When changes are detected in devops/helm/, ArgoCD renders the Helm template
  3. The rendered manifests are compared against the live cluster state
  4. Out-of-sync resources are automatically applied (with selfHeal: true)
  5. 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

kubectl apply -f devops/k8s/gitops/argo-application.yaml

Note: You may see a warning about the applicationsets.argoproj.io CRD 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

  1. CI builds a new image and pushes to GHCR with a digest
  2. Dev: Update values-dev.yaml with the new image digest
  3. Staging: Create a PR promoting the digest from dev to values-staging.yaml
  4. 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:

helm test grokdevops -n grokdevops

This runs the test pod defined in templates/tests/test-connection.yaml to verify the service is responding.