Skip to main content

ArgoCD

Updated Aug 19, 2022 ·

Overview

ArgoCD is a GitOps continuous delivery tool for Kubernetes. It keeps applications in sync with their desired state stored in Git.

  • Automates deployments using Git as a single source of truth.
  • Continuously monitors and syncs applications.
  • Supports multiple clusters with features like RBAC and SSO.

How ArgoCD Works

ArgoCD automatically deploys and ensures the application matches the Git repository. If changes occur, it syncs them automatically.

  • Uses Git repositories to store the desired application state.
  • Compares the live state with the desired state and reports any differences.
  • Supports Kubernetes manifests in different formats:
    • Kustomize
    • Helm charts
    • YAML or JSON files
  • Automatically syncs applications to match their defined state.

Example: Deploying an App with ArgoCD

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
spec:
project: default
source:
repoURL: https://github.com/example/my-app.git
path: manifests
targetRevision: HEAD
destination:
server: https://kubernetes.default.svc
namespace: my-namespace
syncPolicy:
automated:
prune: true
selfHeal: true

Expected Result:

  • ArgoCD deploys my-app to the Kubernetes cluster.
  • Automatically syncs changes from Git when updated.
  • Ensures live state matches the target state.

Key Concepts

ConceptDescription
ApplicationA Kubernetes resource managed by ArgoCD, defining the source (Git) and destination (Kubernetes cluster).
Application Source TypeSpecifies how the app is built, using tools like Helm, Kustomize, or raw manifests.
ProjectGroups multiple applications, useful when multiple teams use ArgoCD.
Target StateThe desired application state stored in Git.
Live StateThe current state of resources (pods, secrets, configmaps) in the cluster.
SyncThe process of making the live state match the target state.
Sync StatusShows whether the application matches the state in Git.
Sync Operation StatusIndicates if the sync succeeded or failed.
RefreshCompares the latest Git code with the live state and detects differences.
Health AssessmentEvaluates the overall health of an application based on Kubernetes resources.

ArgoCD Architecture

ArgoCD helps manage and deploy applications in Kubernetes environments. It uses Git as the source of truth to keep applications synchronized and ensures consistent deployment across environments.

  • Kubernetes Controller

    • ArgoCD runs as a controller in a Kubernetes cluster.
    • Accessible via CLI or UI for app management.
  • Operations

    • Create/manage applications.
    • Configure SSO and sync projects.
  • State Monitoring & Sync

    • Compares live state with Git's desired state.
    • Auto-applies changes from Git to environments.
  • Webhooks

    • Set up Git webhooks to notify ArgoCD on Git events.
  • ArgoCD API Server

    • Exposes gRPC/REST APIs.
    • Used by CLI, UI, and CI/CD pipelines.
  • Multi-Cluster Support

    • Deploy resources across multiple Kubernetes clusters.
  • Metrics & Notifications

    • Prometheus metrics and Grafana integration.
    • Notification service supports Slack, email, GitHub, etc.

Installation

Install Argo CD:

  • Create the argocd namespace.
  • Apply the Argo CD manifest.
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Install Argo CD CLI:

  • Download the CLI from GitHub releases.
  • Make it executable and move it to /usr/local/bin/.
wget https://github.com/argoproj/argo-cd/releases/download/v2.4.11/argocd-linux-amd64
mv argocd-linux-amd64 argocd
chmod +x argocd
sudo mv argocd /usr/local/bin/

Verify installation:

  • Check Argo CD services.
  • Change argocd-server service type to NodePort.
kubectl get pods -n argocd
kubectl edit svc argocd-server -n argocd # Change type to NodePort

Access the UI

Access Argo CD UI:

  • Get the external IP and NodePort.
  • Open <EXTERNAL_IP>:<NODE_PORT> in a browser.
  • Accept the self-signed certificate.
kubectl get svc argocd-server -n argocd

Login to Argo CD:

  • Retrieve the default admin password.
  • Decode the password and log in.
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d

Use the username admin and the decoded password to log in.

Access the CLI

Log in via CLI:

  • Use argocd login with the server IP.
  • Accept the self-signed certificate.
argocd login <ARGOCD_SERVER_IP> --username admin --password <DECODED_PASSWORD> --insecure

Check Argo CD Setup:

  • List clusters and applications.
argocd cluster list
argocd app list

No applications exist yet, but Argo CD is ready to deploy them.