Using ArgoCD for GitOps in Kubernetes Clusters

Listen to this Post

Featured Image
ArgoCD provides a robust GitOps approach for managing applications in Kubernetes clusters. It excels in declarative management of Kubernetes resources and enables centralized control of multiple clusters. While not as scalable as tools like Fleet for large deployments, ArgoCD is ideal for smaller setups, offering rollback capabilities for changes made outside Git repositories and maintaining a clear infrastructure change history via Git.

You Should Know:

1. Installing ArgoCD

Deploy ArgoCD in your Kubernetes cluster using the following commands:

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

2. Accessing the ArgoCD UI

Port-forward to access the ArgoCD dashboard:

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

Then, access it via `https://localhost:8080`.

3. Retrieving the Admin Password

Get the initial admin password:

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

4. Connecting a Git Repository

Configure ArgoCD to sync with a Git repo:

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

5. Enforcing GitOps (Auto-Sync & Rollback)

Enable automatic synchronization and self-healing:

argocd app set my-app --sync-policy automated --auto-prune --self-heal 

6. Managing Multiple Clusters

Add an external cluster to ArgoCD:

argocd cluster add <CONTEXT-NAME> --name <CLUSTER-ALIAS> 

7. Monitoring Sync Status

Check application synchronization status:

argocd app get my-app 

8. Rolling Back Changes

If a deployment fails, rollback using:

argocd app rollback my-app <REVISION-NUMBER> 

9. Using ArgoCD CLI for Automation

Install the ArgoCD CLI:

curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd 
rm argocd-linux-amd64 

10. Integrating with CI/CD Pipelines

Trigger ArgoCD sync via webhooks:

argocd app sync my-app --async --prune 

What Undercode Say

ArgoCD simplifies Kubernetes deployments by enforcing GitOps principles, ensuring infrastructure changes are traceable and reversible. Its ability to manage multiple clusters from a single interface makes it a powerful tool for DevOps teams. While not suited for massive-scale deployments, it excels in small to medium environments. Future enhancements may include better scalability and deeper integration with CI/CD systems.

Expected Output:

– ArgoCD UI accessible at `https://localhost:8080`
– Automated sync and rollback configurations
– Multi-cluster management via CLI
– Git-based history of infrastructure changes

Prediction

As Kubernetes adoption grows, GitOps tools like ArgoCD will become standard in DevOps workflows, with increased focus on security and multi-cluster scalability.

URL: Hub and Spoke Architecture Project with ArgoCD

References:

Reported By: Darryl Ruggles – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram