How to Set Up a Kubernetes CI/CD Pipeline with ArgoCD (GitOps)

ArgoCD implements GitOps for Kubernetes — continuously syncing cluster state to match what's declared in a Git repository. This guide covers setting up ArgoCD for automated, Git-driven deployments.

How This Relates to General GitOps Concepts

See GitOps Basics: Managing Infrastructure Through Git for the underlying principles — ArgoCD is a mature, purpose-built implementation of GitOps specifically for Kubernetes, handling the continuous reconciliation between your Git repository's declared state and your cluster's actual running state.

Step 1 — Install ArgoCD

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Step 2 — Access the ArgoCD UI

kubectl port-forward svc/argocd-server -n argocd 8080:443
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d

Step 3 — Define an Application Pointing to Your Git Repository

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/yourorg/k8s-manifests.git
    targetRevision: main
    path: myapp
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Points ArgoCD at your Git repository containing Kubernetes manifests — selfHeal: true means ArgoCD automatically corrects any manual drift from the declared state, and prune: true removes resources no longer present in Git.

Step 4 — Trigger a Sync

argocd app sync myapp

With automated sync policy enabled, ArgoCD applies this automatically on detecting Git changes; manual sync is also available for controlled, deliberate deployment timing if you prefer not to fully automate.

The Deployment Workflow with ArgoCD

  1. Developer commits application code changes, CI builds and pushes a new container image
  2. A separate step (manual or automated) updates the image tag in your Kubernetes manifests repository
  3. ArgoCD detects the Git change and automatically syncs the cluster to match

Separating Application Code Repository from Manifests Repository

A common GitOps pattern: your application source code lives in one repository, while Kubernetes manifests (referencing specific image tags) live in a separate repository — keeps deployment configuration changes cleanly separated from application code changes.

Setting Up Automated Image Tag Updates

Consider tooling (ArgoCD Image Updater, or a CI step that commits manifest changes) to automatically update image tags in your manifests repository when new images are built — completes the automation loop from code commit to deployed change.

Monitoring Sync Status and Health

argocd app get myapp

ArgoCD tracks both sync status (does cluster state match Git) and health status (are the deployed resources actually healthy) — both matter; a synced but unhealthy application still needs attention.

Rolling Back with ArgoCD

argocd app rollback myapp

Since deployment history is tied to Git history, rollback is naturally supported — either through ArgoCD's own rollback command, or simply reverting the relevant Git commit and letting ArgoCD sync the reverted state.

Common Errors

ArgoCD shows "OutOfSync" but won't auto-correct — verify selfHeal is genuinely enabled if you expect automatic correction of manual drift; without it, ArgoCD detects drift but waits for manual sync approval rather than auto-correcting.

Continue Reading

Browse more articles in Kubernetes & Container Orchestration.

  • argocd kubernetes gitops, argocd setup tutorial, kubernetes gitops pipeline, argocd application sync
  • 0 Kasutajad peavad seda kasulikuks
Kas see vastus oli kasulik?

Seotud artiklid

What Is Kubernetes and When Do You Need It on a VPS?

Kubernetes is a container orchestration platform — it automates deploying, scaling, and...

How to Install a Single-Node Kubernetes Cluster with k3s

k3s is a lightweight, certified Kubernetes distribution designed to run efficiently on modest...

How to Install kubeadm and Set Up a Multi-Node Kubernetes Cluster

kubeadm is the official tool for bootstrapping a standard, full-featured Kubernetes cluster. This...

Kubernetes Pods, Deployments & Services Explained

Understanding these three core Kubernetes objects — Pods, Deployments, and Services —...

How to Expose Applications with a Kubernetes Ingress Controller (Nginx Ingress)

An Ingress lets you route external HTTP/HTTPS traffic to multiple services within your cluster...