Skip to content

ArgoCD GitOps

Deploy applications automatically from Git using ArgoCD.

Time: ~20 minutes Difficulty: Intermediate

  • Installing ArgoCD on Minikube with Terraform
  • Creating ArgoCD Application resources
  • The App-of-Apps pattern
  • Auto-sync, self-heal, and auto-prune
  • ArgoCD Projects for access control
  • Terraform v1.0+
  • Demos simple-app, helm, and kustomize must exist in this repo (ArgoCD deploys them from Git)
Terminal window
cd demos/argocd/terraform/
terraform init
terraform apply

Terraform installs ArgoCD via Helm into the argocd namespace.

Terminal window
# Port-forward the ArgoCD server
kubectl port-forward svc/argocd-server -n argocd 8080:80
# Get the admin password
kubectl -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d

Open http://localhost:8080 and log in with username admin and the password above.

Deploy all applications at once:

Terminal window
kubectl apply -f applications/app-of-apps.yaml

This creates a parent application that manages all child applications:

ApplicationSource PathWhat It Deploys
simple-appdemos/simple-app/manifestsPlain nginx deployment
helm-appdemos/helm/chartHelm-based web app
kustomize-devdemos/kustomize/overlays/developmentDev overlay
kustomize-proddemos/kustomize/overlays/productionProd overlay
Terminal window
kubectl apply -f applications/1-simple-app.yaml
kubectl apply -f applications/2-helm-app.yaml
kubectl apply -f applications/3a-kustomize-dev.yaml
kubectl apply -f applications/3b-kustomize-prod.yaml

In the ArgoCD UI, you should see all applications with a green “Synced” and “Healthy” status.

From the CLI:

Terminal window
kubectl get applications -n argocd
applications/
app-of-apps.yaml # Meta-application managing all others
1-simple-app.yaml # Points to demos/simple-app/manifests
2-helm-app.yaml # Points to demos/helm/chart
3a-kustomize-dev.yaml # Points to demos/kustomize/overlays/development
3b-kustomize-prod.yaml # Points to demos/kustomize/overlays/production
projects/
project-dev.yaml # RBAC: restricts which repos and namespaces are allowed
terraform/
provider.tf # Helm + Kubernetes providers
argocd.tf # ArgoCD Helm release
variables.tf # Configurable inputs
values.yaml # ArgoCD Helm values
outputs.tf # Post-install instructions

Each ArgoCD Application watches a Git path. When you push a change, ArgoCD detects the diff and syncs the cluster to match.

Key sync policies:

  • Auto-sync: applies changes without manual approval
  • Self-heal: reverts manual cluster edits to match Git
  • Auto-prune: deletes resources removed from Git
  1. Edit demos/simple-app/manifests/deployment.yaml, change replicas: 2 to replicas: 5, commit and push. Watch ArgoCD sync automatically.

  2. Manually delete a pod and watch ArgoCD self-heal:

    Terminal window
    kubectl delete pod -l app=simple-nginx -n simple-app
  3. Check sync status from CLI:

    Terminal window
    kubectl get applications -n argocd -o wide
Terminal window
# Remove all applications
kubectl delete -f applications/app-of-apps.yaml
# Uninstall ArgoCD
cd terraform/
terraform destroy
# Remove namespace
kubectl delete namespace argocd

See docs/deep-dive.md for a detailed explanation of GitOps principles, ArgoCD architecture, sync policies, the App-of-Apps pattern, Projects/RBAC, and troubleshooting.

Move on to Cert-Manager to automate TLS certificate management.