Kubernetes  

How to Deploy Applications on Kubernetes Using ArgoCD GitOps Workflow?

Introduction

Deploying applications on Kubernetes is powerful, but doing it manually again and again using kubectl can become slow, error-prone, and hard to manage. Many teams face issues like missed updates, wrong configurations, and no clear history of changes.

This is where GitOps with ArgoCD helps.

In simple words, GitOps means: your Git repository becomes the main control system for your application deployment. You just push changes to Git, and ArgoCD automatically updates your Kubernetes cluster.

This approach is widely used in modern DevOps, cloud computing, and CI/CD pipelines because it is reliable, traceable, and easy to scale.

What is GitOps in Kubernetes?

GitOps is a deployment approach where your entire Kubernetes setup (applications, configs, services) is stored in a Git repository.

How GitOps works in simple words

  • You write Kubernetes YAML files (Deployment, Service, etc.)

  • You store them in GitHub, GitLab, or Bitbucket

  • Any change in Git triggers deployment automatically

  • The cluster always matches what is written in Git

Real-life example

Think of Git like a “remote control” for your infrastructure.

Before GitOps:
You manually press buttons (kubectl commands) every time.

After GitOps:
You just change something in Git, and everything updates automatically.

This makes Kubernetes deployment faster and safer.

What is ArgoCD?

ArgoCD is a GitOps continuous delivery (CD) tool made specifically for Kubernetes.

It watches your Git repository and ensures that your Kubernetes cluster always stays in sync with it.

Key features of ArgoCD

  • Automated deployment
    Whenever you push changes to Git, ArgoCD deploys them automatically.

  • Self-healing system
    If someone manually changes something in Kubernetes, ArgoCD detects it and fixes it.

  • Easy rollback
    You can go back to any previous version directly from the UI.

  • Visual dashboard
    ArgoCD provides a UI where you can see app status, sync state, and errors.

Simple understanding

ArgoCD = Git watcher + Kubernetes deployer

How ArgoCD GitOps Workflow Works

Let’s understand the full GitOps workflow step by step.

Step-by-step flow

  • Developer updates code or YAML in Git

  • Code is pushed to repository (GitHub/GitLab)

  • ArgoCD detects the change

  • ArgoCD compares desired state (Git) vs actual state (cluster)

  • ArgoCD applies required changes

Before vs After GitOps

Before using GitOps:

  • Manual deployments using kubectl

  • High chances of mistakes

  • No clear version tracking

After using GitOps with ArgoCD:

  • Fully automated deployments

  • Everything tracked in Git history

  • Easy rollback and debugging

This is why GitOps is becoming standard in DevOps.

Prerequisites for ArgoCD Kubernetes Deployment

Before starting, make sure your environment is ready.

Required tools

  • Kubernetes cluster (Minikube, EKS, GKE, AKS)

  • kubectl installed and configured

  • Git repository (GitHub recommended)

  • Basic knowledge of YAML and Kubernetes concepts

Beginner tip

If you are new, start with Minikube locally. It is simple and good for practice.

Step 1: Install ArgoCD in Kubernetes Cluster

First, create a separate namespace for ArgoCD.

kubectl create namespace argocd

Now install ArgoCD using official manifests:

kubectl apply -n argocd -f

What happens internally?

  • ArgoCD server is created

  • Controller and repo server are installed

  • Required services and pods are started

You can verify installation using:

kubectl get pods -n argocd

Step 2: Access ArgoCD Dashboard (UI)

To access ArgoCD UI locally:

kubectl port-forward svc/argocd-server -n argocd 8080:443

Open browser:

https://localhost:8080

Get login password

kubectl get secret argocd-initial-admin-secret -n argocd -o yaml

Decode it and login using:

  • Username: admin

Why UI is important?

  • Monitor deployments

  • Check sync status

  • Debug issues easily

Step 3: Prepare Git Repository for Kubernetes Deployment

Now create a Git repository that contains Kubernetes YAML files.

Recommended folder structure

app/
  deployment.yaml
  service.yaml

Example deployment file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: nginx
          ports:
            - containerPort: 80

Simple explanation

  • replicas = number of pods

  • image = application container

  • containerPort = app port

This file tells Kubernetes how to run your application.

Step 4: Connect Git Repository to ArgoCD

Now link your Git repository with ArgoCD.

Using UI

  • Go to Settings → Repositories

  • Click Add Repository

  • Enter repo URL and credentials

Using CLI

argocd repo add

Why this step matters?

Without connecting Git, ArgoCD cannot read your application configuration.

Step 5: Create Application in ArgoCD

Now create an application that connects Git and Kubernetes.

argocd app create my-app \
--repo \
--path app \
--dest-server \
--dest-namespace default

What each parameter means

  • repo = your Git repository

  • path = folder where YAML exists

  • dest-server = Kubernetes cluster

  • namespace = where app will run

This step defines your deployment pipeline.

Step 6: Sync Application (Deploy to Kubernetes)

Now deploy your application:

argocd app sync my-app

What happens here?

  • ArgoCD reads YAML from Git

  • Compares with cluster

  • Creates/updates resources

Output

Your application will be running inside Kubernetes.

Step 7: Enable Auto-Sync (Continuous Deployment)

To automate deployment completely:

argocd app set my-app --sync-policy automated

What this does

  • Every Git push triggers deployment

  • No manual sync needed

This is the core of GitOps automation.

Step 8: Update Application (Real DevOps Example)

Let’s say you want to scale your app.

Before:

replicas: 2

After:

replicas: 3

What you do

  • Update file in Git

  • Commit and push

What ArgoCD does

  • Detects change

  • Applies update

  • Scales pods automatically

No kubectl command needed.

Step 9: Rollback Deployment Using ArgoCD

If deployment fails or bug appears:

Using UI

  • Open ArgoCD dashboard

  • Select previous version

  • Click Rollback

Why rollback is powerful

  • Quick recovery from failure

  • No need to manually fix configs

  • Saves production downtime

Advantages of ArgoCD GitOps Workflow

  1. Fully automated deployment

    No need for manual commands, everything runs automatically.

  2. Version control with Git

    Every change is tracked and reversible.

  3. Faster debugging

    You can check exactly what changed and when.

  4. Self-healing system

    If cluster state changes manually, ArgoCD fixes it.

  5. Better team collaboration

    Developers and DevOps teams work using Git workflows.

Disadvantages of ArgoCD GitOps

  1. Initial setup complexity

    Beginners may find setup confusing.

  2. Requires Git discipline

    All changes must go through Git only.

  3. Learning curve

    Understanding GitOps takes some time.

Common Mistakes to Avoid in Kubernetes GitOps

  1. Manual changes in cluster

    Avoid using kubectl directly after GitOps setup.

  2. Poor Git structure

    Keep your repo clean and organized.

  3. Not enabling auto-sync

    Without this, GitOps becomes semi-manual.

  4. Hardcoded values

    Use environment configs instead of hardcoding.

Real-World Use Case of ArgoCD GitOps

A startup was deploying apps manually using kubectl.

Problems faced

  • Frequent deployment errors

  • No version tracking

  • Difficult rollback

After implementing ArgoCD

  • Deployments became automatic

  • Rollbacks reduced downtime

  • System became stable and scalable

This is why companies adopt GitOps.

Summary

Deploying applications on Kubernetes using ArgoCD GitOps workflow makes the entire process automated, reliable, and easy to manage. Instead of manually deploying applications, you simply push changes to Git, and ArgoCD ensures your Kubernetes cluster stays updated. This approach improves deployment speed, reduces human errors, and provides complete visibility through version control. For modern DevOps engineers and developers, learning Kubernetes GitOps with ArgoCD is an essential skill for building scalable and production-ready systems.