Screenshot from the article

Introduction

In the modern DevOps landscape, GitOps has emerged as a revolutionary approach to continuous delivery. Argo CD is a powerful tool designed to manage Kubernetes deployments using Git as the source of truth. It ensures that the desired application state defined in Git is always reflected in the Kubernetes cluster.

In this blog, we will explore how to set up Argo CD, walk through real-world examples, discuss advanced configurations, and cover FAQs.

Why Argo CD?

🔹 Key Benefits

  • Declarative and Automated: Ensures Kubernetes state matches the Git repository
  • Continuous Sync: Automatically detects and fixes drift between Git and cluster state
  • Multi-Cluster Management: Deploy applications across multiple Kubernetes clusters
  • RBAC and Security: Securely manage deployments with role-based access control
  • Helm & Kustomize Support: Supports Helm charts and Kustomize overlays
  • Web UI & CLI: Provides both a web-based UI and CLI for ease of use

🚀 Setting Up Argo CD

1️⃣ Install Argo CD

First, install Argo CD in a Kubernetes cluster:

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

2️⃣ Access the Argo CD UI

Expose the Argo CD API server via port-forwarding:

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

Retrieve the initial admin password:

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

Log in using the UI at https://localhost:8080 or via CLI:

argocd login localhost:8080 --username admin --password <password>

3️⃣ Deploy an Application

Add a new application from a Git repository:

argocd app create my-app \
  --repo https://github.com/example/repo.git \
  --path my-app \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace default

Sync the application:

argocd app sync my-app

🌟 Real-World Advanced Use Cases

1️⃣ Multi-Cluster Deployment

Argo CD can manage applications across multiple clusters. First, register a new cluster:

argocd cluster add <context-name>

Then deploy an app to a specific cluster:

argocd app create multi-cluster-app \
  --repo https://github.com/example/repo.git \
  --path my-app \
  --dest-server <cluster-api-url> \
  --dest-namespace prod

2️⃣ Automating Rollbacks on Deployment Failures

Enable auto-sync and rollback in Argo CD:

syncPolicy:
  automated:
    prune: true
    selfHeal: true
  retry:
    limit: 3
    backoff:
      duration: 5s
      factor: 2

If a deployment fails, Argo CD will automatically revert to the last working state.

3️⃣ Managing Helm Charts with Argo CD

Argo CD supports Helm charts as application sources:

argocd app create helm-app \
  --repo https://charts.helm.sh/stable \
  --helm-chart mychart \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace dev

4️⃣ Implementing RBAC for Secure Access

Define role-based access control (RBAC) policies in argocd-rbac-cm.yaml:

policy.default: role:readonly
policy.csv: |
  p, user, applications, sync, my-app, allow
  g, devs, applications, get, *, allow

Apply the RBAC configuration:

kubectl apply -f argocd-rbac-cm.yaml -n argocd

5️⃣ Using Notifications with Slack

Enable Slack notifications when deployments succeed/fail:

argocd notifications template create deployment-failed \
  --body "Application {{.app.metadata.name}} failed to deploy!"
argocd notifications trigger create on-sync-status-failed \
  --template deployment-failed \
  --subscription slack-channel=my-team

🔥 Best Practices

✔️ Use GitOps workflows to track all changes

✔️ Enable RBAC to prevent unauthorized changes

✔️ Implement Webhook triggers for auto-deployments

✔️ Use health checks to ensure reliable rollouts

✔️ Monitor drift detection and enable alerts

✔️ Leverage Kustomize/Helm for templating configurations

❓ FAQs

1️⃣ What is the difference between Argo CD and Flux CD?

Argo CD provides a web UI, CLI, and advanced automation, while Flux CD is a lightweight, CLI-driven alternative.

2️⃣ How does Argo CD handle secrets?

Argo CD doesn’t manage secrets natively. Use Sealed Secrets, HashiCorp Vault, or External Secrets Operator.

3️⃣ Can I use Argo CD for non-Kubernetes workloads?

No, Argo CD is specifically designed for Kubernetes deployments.

4️⃣ How do I troubleshoot Argo CD sync failures?

  • Check application logs: argocd app logs my-app
  • Review sync history: argocd app history my-app
  • Verify Kubernetes events: kubectl describe pod <pod-name>

5️⃣ How do I upgrade Argo CD?

To upgrade, apply the latest manifests:

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

Conclusion

Argo CD is an essential GitOps tool for Kubernetes, ensuring reliable, automated, and scalable application deployments. By integrating multi-cluster management, Helm, RBAC, and notifications, teams can streamline their CI/CD processes.

Ready to level up your DevOps game? 🚀 Start using Argo CD today and simplify your Kubernetes deployments!

👉 What challenges have you faced with Argo CD? Drop a comment below

📢 Have questions or feedback? Drop a comment below or connect with me on Twitter/X@spysood!

Originally published on Medium.