Showing posts with label ArgoCD. Show all posts
Showing posts with label ArgoCD. Show all posts

Thursday, 5 March 2026

Introduction to ArgoCD


ArgoCD is a tool for deploying applications in Kubernetes cluster following the GitOps principles. 

Argo CD is a declarative, GitOps-based continuous delivery (CD) tool designed specifically for Kubernetes. It acts as a controller that monitors running applications, compares their live state to the desired state defined in a Git repository, and automatically syncs them to ensure consistency. 

Key Aspects of an Argo CD Application:
  • GitOps Source of Truth: Git repositories hold the desired state (manifests, Helm charts, Kustomize configs), which Argo CD pulls to apply to clusters.
  • Automated Synchronization: It automatically detects "OutOfSync" applications—where the live cluster state differs from Git—and can automatically or manually sync them to match.
  • Continuous Monitoring: It acts as a Kubernetes controller that continuously monitors applications.
  • Visualization & Management: It provides a web UI to visualize application structure, monitor status, and manage rollbacks.
  • Key Capabilities: Supports automated deployment, drift detection, and easy rollbacks. 

Argo CD is often used to ensure that the actual state of a Kubernetes cluster matches the configuration stored in a Git repository, making the deployment process more reliable and transparent.

ArgoCD GitOps flow:
  • Commit and push infra code changes (Terraform, Helm values etc) to the main branch of your GitHub repository.
  • ArgoCD Sync:
    • Manual: Log in to our ArgoCD Dashboard and click the "Sync" or "Refresh" button on the psmdb-default-sharded application.
    • Automatic: If "Self-Heal" or "Auto-Sync" is enabled, ArgoCD will detect the Git change within ~3 minutes and apply it to the cluster automatically.
  • Monitor the Operator: Once ArgoCD syncs, infra will get changed e.g. operators will see the updated custom resources and then trigger the further actions.

Installation


Installing ArgoCD in a Kubernetes cluster is primarily done using manifests or Helm charts. The most common and recommended approach for beginners is using the Official Argo CD Manifests. 

Prerequisites:
  • A running Kubernetes cluster (v1.22 or later).
  • kubectl command-line tool installed and configured to your cluster.
  • At least 2GB of available memory in your cluster.

Applications


ArgoCD defines custom Kubernetes objects like ApplicationAppProject, settings...which can be defined declaratively using Kubernetes manifests and deployed via kubectl apply to the ArgoCD namespace which is argocd by default.

To check ArgoCD applications:

% kubectl get applications -A        
NAMESPACE   NAME                    SYNC STATUS   HEALTH STATUS
argocd      my-app                  Synced        Progressing 



Dashboard


If you don't know the url of the ArgoCD dashboard, find the IP of the ArgoCD server and port-forward it:

% kubectl get svc argocd-server -n argocd
NAME          TYPE      CLUSTER-IP    EXTERNAL-IP PORT(S)        AGE
argocd-server ClusterIP 172.21.103.127 <none>     80/TCP,443/TCP 1d


By default, ArgoCD includes a built-in admin user with full super-user access. For better security practices, it is recommended that you use the admin account only for the initial configuration, then disable it once all required users have been added.

For this example, we can stick to this default admin user. Its password can be obtain via this command:

% kubectl get secret \
argocd-initial-admin-secret \
-n argocd \
-o jsonpath="{.data.password}" \
| base64 -d

Port forwarding:

% kubectl port-forward svc/argocd-server -n argocd 8080:443
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
Handling connection for 8080
Handling connection for 8080
Handling connection for 8080
Handling connection for 8080
Handling connection for 8080
Handling connection for 8080
...

We can now open the address http://localhost:8080/ in the browser to get the ArgoCD dashboard and log in with credentials above.

If there are no application registered with ArgoCD, we will see something like this:



application.yaml vs applicationset.yaml


In the world of Argo CD and Kubernetes GitOps, these two files represent different levels of automation. 

1. application.yaml


An Application is the basic unit of Argo CD. This file defines a single link between a specific Git repository (the source) and a specific Kubernetes cluster/namespace (the destination).

  • The Goal: To tell Argo CD: "Take the code from this folder and make sure it looks like that in my cluster."
  • Key Components:
    • Project: The logical group it belongs to.
    • Source: Argo CD needs three pieces of information to find our files:
      • repoURL: Git URL. Which "building" (repository) do I go to?
      • targetRevision: revision (branch/tag), Which "floor" (branch/tag/commit) am I looking at?
      • path (mandatory): path to the manifests. Which "room" (folder) contains the manifests?
    • Destination: The target cluster URL and namespace.
    • Sync Policy: Whether to automatically sync changes or require a manual button press.


Example Snippet:

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


Argo CD is completely "tool-agnostic." It doesn't care if you use Helm, Kustomize, or just a folder full of .yaml files; it just needs to know where they are.

How Argo CD Decides


When Argo CD looks at the path you provided, it follows this logic:
  • Does it see Chart.yaml? -> It uses Helm.
    • Argo CD uses values.yaml by default if it detects that the directory specified in the path is a Helm chart.
  • Does it see kustomization.yaml? -> It uses Kustomize.
  • Does it see only .yaml or .json files? -> It uses Plain Manifests.