Cloud Architecture

GitOps with ArgoCD: Managing Kubernetes Deployments

Master GitOps workflows for Kubernetes with ArgoCD. Learn to automate, secure, and streamline your deployments using Git as the single source of truth.

Khader Vali September 22, 2026 16 min read

GitOps with ArgoCD: Managing Kubernetes Deployments

As senior engineers, we’re constantly striving for more efficient, reliable, and secure ways to deploy and manage our applications in dynamic environments. Kubernetes, while powerful, introduces its own set of operational challenges. This is where GitOps shines, offering a paradigm shift in how we approach continuous delivery. At the heart of a robust GitOps strategy for Kubernetes lies a powerful tool like ArgoCD. This article will dive deep into the GitOps workflow, demonstrating how ArgoCD acts as your cluster’s vigilant guardian, ensuring its state perfectly mirrors your Git repository.

We’ll explore the core principles of GitOps, understand why it’s becoming the de facto standard for Kubernetes deployments, and then get hands-on with ArgoCD – from its architecture and setup to advanced deployment patterns and best practices. By the end, you’ll have a comprehensive understanding of how to implement a secure, scalable, and auditable GitOps pipeline for your Kubernetes infrastructure.

Understanding GitOps: The Declarative Future of DevOps

Before we introduce ArgoCD, let’s firmly establish what GitOps is and why it’s such a transformative approach. GitOps isn’t just a tool; it’s an operational framework that takes the best practices from Git-based development and applies them to infrastructure and application deployment.

What is GitOps?

At its core, GitOps defines an operating model where the desired state of an application and its infrastructure is declaratively described and stored in Git. An automated process then ensures that the actual state of the system converges with this desired state, continuously and autonomously.

Think of it this way: instead of imperative commands telling your cluster what to do (e.g., kubectl apply -f my-deployment.yaml), you declare *what you want* your cluster to look like by committing YAML manifests to a Git repository. A specialized operator (like ArgoCD) then observes this Git repository and the cluster, acting as a reconciliation engine to bridge any gaps.

The Four Core Principles of GitOps

Coined by Weaveworks, GitOps is built upon four fundamental principles:

  1. Declarative: The entire system described declaratively. This means all configuration, infrastructure, and application definitions are expressed in a format that describes the desired end state, not the steps to achieve it (e.g., YAML, JSON). Kubernetes itself is a declarative system, making it a perfect fit for GitOps.
  2. Versioned and Immutable: The desired state is stored in Git, which provides a single source of truth. Every change to the desired state is a commit, offering an immutable, auditable, and version-controlled record. This enables easy rollbacks, tracking, and collaboration.
  3. Pulled Automatically: Changes to the desired state are automatically applied to the system by an agent (controller) running inside the environment. This “pull” model contrasts with traditional “push” CI/CD, where external pipelines push changes to the cluster. The pull model enhances security by reducing the need for external systems to have direct write access to the cluster API.
  4. Continuously Reconciled: The agent continuously observes the actual state of the system and compares it to the desired state in Git. If any drift is detected (e.g., someone manually changed a resource on the cluster), the agent automatically reconciles the actual state back to the desired state defined in Git. This ensures consistency and prevents configuration drift.

Why GitOps? Benefits for Modern DevOps

Embracing GitOps offers a multitude of benefits that address many common challenges in managing Kubernetes deployments:

  • Increased Speed: Faster, more frequent, and automated deployments reduce manual overhead and accelerate time-to-market.
  • Enhanced Reliability: The declarative nature and continuous reconciliation minimize human error and configuration drift. Rollbacks are as simple as reverting a Git commit.
  • Improved Security: The “pull” model means your CI pipeline doesn’t need direct Kubernetes API credentials, reducing the attack surface. All changes are reviewed via standard Git workflows (e.g., pull requests).
  • Better Auditability and Traceability: Every change to your infrastructure and applications is a Git commit, providing a complete, immutable audit log of who changed what, when, and why.
  • Easier Disaster Recovery: Rebuilding an environment is as simple as pointing ArgoCD to your Git repository – the desired state is fully recoverable from Git.
  • Simplified Rollbacks: Reverting to a previous stable state is a Git revert away, making error recovery swift and confident.
  • Consistency Across Environments: By using the same Git repository and principles, maintaining consistency across development, staging, and production environments becomes much easier.

Kubernetes Deployment Challenges Before GitOps

Before GitOps, managing Kubernetes deployments often involved a mix of manual operations and traditional CI/CD pipelines that pushed changes directly to the cluster. While functional, these approaches introduced several pain points:

  • Configuration Drift: Manual modifications to cluster resources (e.g., a quick kubectl edit) can lead to the actual cluster state diverging from the intended state. Tracking these changes becomes nearly impossible, leading to inconsistencies and debugging nightmares.
  • Lack of Audit Trail: Who deployed what, when, and why? Without Git as the single source of truth, tracing deployment history and changes can be fragmented across CI logs, internal wikis, or even personal recollections.
  • Security Concerns (Push Model): Traditional CI/CD pipelines often require Kubernetes API credentials with significant privileges to push deployments. This creates a security risk, as a compromised CI system could gain direct control over your clusters.
  • Complexity with Multiple Environments/Clusters: Managing distinct configurations for development, staging, and production, or across multiple clusters, can become unwieldy without a centralized, version-controlled system. Copy-pasting YAML files often leads to errors and inconsistencies.
  • Difficult Rollbacks: Reverting to a previous working state can be complex if there isn’t a clear, versioned history of all deployed artifacts. Identifying the exact previous configuration can be a manual and error-prone process.
  • Debugging and Troubleshooting: When issues arise, understanding the exact state of the cluster and how it got there is crucial. Without a clear historical record, diagnosing problems becomes significantly harder.

GitOps, particularly with a tool like ArgoCD, directly addresses these challenges by enforcing a declarative, version-controlled, and continuously reconciled approach to managing Kubernetes.

<

GitOps with ArgoCD: Managing Kubernetes Deployments
Generated Image

>

Introducing ArgoCD: The GitOps Controller for Kubernetes

ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It’s designed to automate the deployment, synchronization, and management of applications within Kubernetes clusters, using Git repositories as the definitive source of truth for desired application states.

What is ArgoCD?

ArgoCD operates as a Kubernetes controller that continuously monitors your Git repositories for changes to application manifests (YAML files, Helm charts, Kustomize configurations). When it detects a difference between the desired state in Git and the actual state of your applications in the cluster, it automatically (or manually, depending on configuration) synchronizes the cluster to match the Git repository. This “pull” model is a cornerstone of GitOps, as it enables the cluster to pull configurations rather than external CI/CD pipelines pushing them.

How ArgoCD Fits into the GitOps Paradigm

ArgoCD embodies all four principles of GitOps:

  • Declarative: It consumes declarative Kubernetes manifests from Git.
  • Versioned and Immutable: Git is its single source of truth, leveraging Git’s versioning for all configurations.
  • Pulled Automatically: It runs inside Kubernetes and pulls changes from Git, eliminating the need for external systems to push.
  • Continuously Reconciled: It constantly monitors Git and the cluster, ensuring the cluster’s state matches Git.

Key Features of ArgoCD

ArgoCD offers a rich set of features that make it a powerful GitOps tool:

  • Automated Synchronization: Automatically updates applications in the cluster based on changes in Git.
  • User Interface (UI): A feature-rich web UI provides real-time visibility into application health, status, and synchronization state across all your clusters. It offers a clear, hierarchical view of Kubernetes resources.
  • Command-Line Interface (CLI): A powerful CLI for managing applications, projects, and repositories programmatically or for scripting.
  • Multi-Cluster Support: Manage applications across multiple Kubernetes clusters from a single ArgoCD instance.
  • Application Health Checks: Monitors the health of deployed applications and resources.
  • Rollback Capabilities: Easily revert to any previous committed state in Git.
  • Support for Various Manifest Formats: Works seamlessly with plain Kubernetes YAML, Helm charts, Kustomize, and Ksonnet.
  • Access Control (RBAC): Robust role-based access control for managing who can do what within ArgoCD.
  • PreSync, Sync, PostSync Hooks: Lifecycle hooks for complex deployment scenarios (e.g., database migrations).
  • Drift Detection and Remediation: Automatically detects and can optionally remediate any configuration drift from the desired state in Git.

GitOps Architecture with ArgoCD: A Conceptual Overview

Understanding the architecture is crucial to effectively leveraging ArgoCD for your GitOps strategy. The setup generally involves three main components interacting to maintain the desired state of your Kubernetes clusters.

The Three Pillars of ArgoCD Architecture

Imagine the flow of information and control:

  1. Git Repository (The Source of Truth):
    • This is where all your Kubernetes application manifests, infrastructure configurations, and potentially Helm charts or Kustomize files reside.
    • It represents the *desired state* of your applications and infrastructure.
    • Changes made here (via pull requests, commits) trigger the GitOps workflow.
    • Typically, you’ll have at least two types of repositories:
      • Application Code Repository: Contains your source code. CI pipeline builds artifacts (e.g., Docker images) from this.
      • Manifest Repository (Config Repository): Contains the Kubernetes YAMLs that declare how your applications (built from the app code repo) should be deployed. This is what ArgoCD monitors.
  2. ArgoCD (The Reconciliation Engine):
    • ArgoCD itself runs as a set of controllers within your Kubernetes cluster (usually a dedicated management cluster or your primary application cluster).
    • Its primary components include:
      • ArgoCD API Server: Exposes the gRPC and REST APIs, and the Web UI.
      • ArgoCD Repository Server: Responsible for cloning Git repositories, caching them, and processing manifests (e.g., rendering Helm charts, applying Kustomize overlays).
      • ArgoCD Application Controller: The core reconciliation engine. It continuously compares the live state of applications in the cluster with the desired state specified in the Git repository (as processed by the Repo Server). If it detects a difference (drift), it performs the necessary actions to bring the live state into sync with the desired state.
      • ArgoCD Dex Server/Keycloak: (Optional) For OIDC authentication integration.
    • ArgoCD is configured with information about your Git repositories and the target Kubernetes clusters it manages.
  3. Kubernetes Cluster(s) (The Target Environment):
    • This is where your applications are actually deployed and run.
    • ArgoCD interacts with the Kubernetes API Server of the target cluster(s) to query their current state and apply changes to match the desired state from Git.

The GitOps Flow with ArgoCD (in words)

Imagine the process unfolding:

  1. A developer makes a change to an application’s source code, pushes it to the Application Code Repository.
  2. The CI pipeline is triggered, builds a new Docker image, and pushes it to a container registry.
  3. The CI pipeline then updates the image tag in the relevant Kubernetes manifest file(s) within the Manifest Repository (e.g., deployment.yaml), and pushes this change as a new commit.
  4. The ArgoCD Application Controller (running in the Kubernetes cluster) continuously polls the Manifest Repository.
  5. It detects the new commit with the updated image tag.
  6. The ArgoCD Repository Server fetches the latest manifests from Git.
  7. The ArgoCD Application Controller compares the desired state (from the fetched manifests) with the current live state of the application in the Kubernetes Cluster.
  8. It identifies that the image tag in the live deployment does not match the desired image tag in Git. This is a detected drift.
  9. Based on its synchronization policy (automatic or manual), ArgoCD issues commands to the Kubernetes API Server to update the application’s deployment (e.g., rolling update to the new image).
  10. The Kubernetes scheduler and controllers then work to converge the cluster to this new desired state.
  11. ArgoCD continuously monitors the health and status of the deployed resources, reporting their synchronization status in its UI/CLI.

This “pull” model fundamentally changes the security posture. ArgoCD, running inside your cluster, needs permissions to deploy resources *within* that cluster. Your external CI pipeline only needs Git write access to update manifest files, not direct cluster access. This reduces the blast radius significantly.

Monorepo vs. Polyrepo for Manifests

When structuring your Git repositories for manifests, you typically face two choices:

  • Monorepo: A single Git repository containing manifests for all applications and environments.
    • Pros: Centralized visibility, easier to manage dependencies between applications, atomic commits across multiple services.
    • Cons: Can become very large, slower cloning, permission management might be trickier if different teams own different parts.
  • Polyrepo: Separate Git repositories for each application or environment.
    • Pros: Clear ownership, faster cloning for individual services, better isolation.
    • Cons: More repositories to manage, harder to get an overall view of the system, potential for inconsistent configurations across services if not managed carefully.

ArgoCD supports both approaches. The choice often depends on team structure, organizational size, and application complexity. For simplicity in this article, we’ll assume a single manifest repository for demonstration, but be aware that real-world scenarios might dictate a polyrepo approach.

Setting Up ArgoCD in Your Kubernetes Cluster

Let’s get ArgoCD up and running. We’ll install it into a dedicated namespace within your Kubernetes cluster. For production environments, you might consider a separate “management” cluster for ArgoCD.

Installation Using kubectl

The simplest way to install ArgoCD is by applying its manifests directly using kubectl.

# 1. Create a new namespace for ArgoCD
kubectl create namespace argocd

# 2. Install ArgoCD using its official manifests
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

This command installs all necessary ArgoCD components (API server, controller, repo server, etc.) into the `argocd` namespace. It might take a few moments for all pods to be up and running.

Accessing the ArgoCD UI

The ArgoCD UI provides an intuitive way to manage your applications. By default, the ArgoCD API server is exposed via a ClusterIP service. To access it from outside the cluster, you can use port-forwarding:

# Forward local port 8080 to the ArgoCD API server port 80 in the argocd namespace
kubectl port-forward svc/argocd-server -n argocd 8080:443

Now, open your web browser and navigate to https://localhost:8080. You’ll likely encounter a certificate warning, which you can safely bypass for local testing.

Retrieving the Initial Admin Password

The initial admin password is automatically generated and stored in a Kubernetes secret. You can retrieve it using the following command:

# Get the password from the argocd-initial-admin-secret
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d; echo

Use admin as the username and the retrieved password to log in to the ArgoCD UI. It’s highly recommended to change this password immediately after logging in (via the UI or CLI).

Changing the Admin Password via CLI

If you prefer using the CLI, first install the ArgoCD CLI tool:

# For macOS with Homebrew
brew install argocd

# For Linux (example for v2.9.3, check latest version on ArgoCD docs)
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/v2.9.3/argocd-linux-amd64
chmod +x /usr/local/bin/argocd

Then, log in to ArgoCD using the CLI and change the password:

# Log in to ArgoCD (if port-forwarding, use localhost:8080)
argocd login localhost:8080 --username admin --password <initial_password> --insecure --grpc-web

# Change the password
argocd account update-password --current-password <initial_password> --new-password <your_new_secure_password>

Remember to replace <initial_password> and <your_new_secure_password> with your actual values. The --insecure flag is needed if you are using the self-signed certificate with port-forwarding. Remove it if you have proper TLS setup.

Connecting Git Repositories and Kubernetes Clusters to ArgoCD

For ArgoCD to function, it needs to know about your Git repositories and the Kubernetes clusters it will manage. By default, ArgoCD manages the cluster it’s installed on. To add external clusters or specify your manifest repository, you’d use the UI or CLI:

# Add a Git repository (e.g., your manifest repo)
argocd repo add https://github.com/your-org/your-manifests.git --username git --password <git_pat_or_password>

# Add another Kubernetes cluster (if managing external clusters)
# This will generate a manifest to apply to the target cluster for ArgoCD to connect.
argocd cluster add <context_name_from_kubeconfig>

For simplicity, for this article, we’ll assume the manifest repository is public or ArgoCD is configured with SSH keys/PATs via its UI/secrets, and we’ll deploy to the cluster ArgoCD is installed on (which is automatically registered as in-cluster).

GitOps Workflow with ArgoCD: A Practical Guide

Now that ArgoCD is set up, let’s walk through a typical GitOps workflow. We’ll define an application, put its manifests in Git, and let ArgoCD deploy it.

Step 1: Define Application Manifests in Git

Our first step is to create a Git repository that will hold our Kubernetes manifests. Let’s create a simple Nginx deployment and service.

Create a new Git repository (e.g., kubernetes-manifests) and add the following files:

# applications/guestbook/base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: guestbook-ui
  labels:
    app: guestbook-ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app: guestbook-ui
  template:
    metadata:
      labels:
        app: guestbook-ui
    spec:
      containers:
      - name: guestbook-ui
        image: gcr.io/google-samples/node-hello:1.0
        ports:
        - containerPort: 80
# applications/guestbook/base/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: guestbook-ui
  labels:
    app: guestbook-ui
spec:
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  selector:
    app: guestbook-ui
  type: ClusterIP # Or LoadBalancer for external access

Structure your repository like this:

kubernetes-manifests/
├── applications/
│   └── guestbook/
│       └── base/
│           ├── deployment.yaml
│           └── service.yaml
└── README.md

Commit these files and push them to your Git repository (e.g., GitHub, GitLab, Bitbucket).

# Example Git commands
git init
git add .
git commit -m "Initial guestbook application manifests"
git branch -M main
git remote add origin https://github.com/your-username/kubernetes-manifests.git
git push -u origin main

Step 2: Create an ArgoCD Application

Now, we need to tell ArgoCD about our new application in Git. We’ll create an ArgoCD Application resource. This resource defines where ArgoCD can find the manifests in Git, which cluster to deploy to, and how to synchronize.

You can create this Application resource directly through the ArgoCD UI, CLI, or by applying a YAML manifest to your cluster (which is the GitOps way to manage ArgoCD itself!). Let’s use the CLI for now, assuming you’ve added your manifest repository to ArgoCD.

# Create the ArgoCD application
argocd app create guestbook-ui \
  --repo https://github.com/your-username/kubernetes-manifests.git \
  --path applications/guestbook/base \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace default \
  --sync-policy automated \
  --auto-prune --self-heal

Let’s break down these parameters:

  • guestbook-ui: The name of our ArgoCD application.
  • --repo: The URL of your Git repository containing the manifests.
  • --path: The path within the Git repository where the manifests for this application reside.
  • --dest-server https://kubernetes.default.svc: Specifies the target Kubernetes cluster. https://kubernetes.default.svc refers to the in-cluster API server (i.e., the same cluster ArgoCD is running on).
  • --dest-namespace default: The Kubernetes namespace where the application should be deployed.
  • --sync-policy automated: ArgoCD will automatically synchronize changes when detected in Git. For production, you might start with --sync-policy manual.
  • --auto-prune: Allows ArgoCD to delete resources from the cluster that are no longer defined in Git.
  • --self-heal: If a resource in the cluster is manually modified (drift detected), ArgoCD will automatically revert it to the state defined in Git.

Alternatively, you could define this ArgoCD Application as a YAML manifest and commit it to a separate Git repository (often called a “management” or “bootstrap” repo) that ArgoCD itself monitors. This is the ultimate Git

Written by

Khader Vali

Senior Software Engineer specializing in cloud architecture, real-time systems, and enterprise-scale applications.

Share this article

Related Articles

Kubernetes for Developers: Deploy, Scale, Manage Containers

Oct 11, 2026 · 15 min read

FinOps: Data-Driven Cloud Cost Optimization for Engineers

Jun 21, 2026 · 18 min read

GitOps with Argo CD: Managing Kubernetes Deployments

Sep 19, 2026 · 14 min read