Home / Technology / GitOps implementation with ArgoCD

GitOps implementation with ArgoCD

Automating Kubernetes Deployments with GitOps and ArgoCD

Introduction

In modern cloud-native environments, automating deployments is a critical requirement for scalability, reliability, and efficiency. Traditional CI/CD pipelines often introduce complexity in managing infrastructure drift and maintaining deployment consistency. GitOps, an operational framework that uses Git as the single source of truth, addresses these challenges by ensuring that infrastructure and application state are declaratively defined and continuously synchronized with the Kubernetes cluster.

This blog explores how we implemented GitOps using ArgoCD, Helm, and Kubernetes to enable automated, version-controlled deployments. The objective of this assignment was to build a seamless CI/CD pipeline where any change pushed to a Git repository automatically reflects in the running application.

Understanding the Problem

Before GitOps, our deployment workflow relied on manual kubectl commands or traditional CI/CD pipelines that pushed changes to Kubernetes clusters via external scripts. This led to:

  • Inconsistent deployments across different environments.
  • Configuration drift between declared and actual cluster state.
  • Operational overhead in managing rollbacks and debugging deployment failures.

By adopting GitOps with ArgoCD, we aimed to:

  • Automate deployments with pull-based synchronization.
  • Ensure declarative infrastructure management.
  • Improve deployment visibility and rollback capabilities.

Key DevOps Tools and Technologies Used

1. ArgoCD

A declarative, GitOps-based Continuous Deployment (CD) tool for Kubernetes. It continuously monitors Git repositories and applies changes to Kubernetes clusters.

2. Kubernetes

A container orchestration platform used to deploy, scale, and manage applications.

3. Helm

A package manager for Kubernetes that simplifies application deployment using Helm charts.

4. Docker

Used to containerize the application and manage dependencies consistently across environments.

5. GitHub

Serves as the single source of truth, where changes are committed, version-controlled, and deployed automatically.

Implementation Steps

Step 1: Deploying ArgoCD on Kubernetes

To install ArgoCD on a Kubernetes cluster, we first created a namespace and applied the official manifests:

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

Once deployed, we exposed the ArgoCD UI:

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

Access ArgoCD UI at http://localhost:8080.

Step 2: Registering the Git Repository in ArgoCD

ArgoCD requires access to a Git repository to monitor changes. We added our GitHub repo:

argocd repo add https://github.com/rahulkarda/gitops-demo2.git 
  --username rahulkarda 
  --password 

This allows ArgoCD to fetch changes and sync them with the Kubernetes cluster.

Step 3: Deploying the Application with ArgoCD

We created an ArgoCD application that automatically syncs with the Git repository.

argocd app create gitops-demo2 
  --repo https://github.com/rahulkarda/gitops-demo2.git 
  --path gitops-demo/charts 
  --dest-server https://kubernetes.default.svc 
  --dest-namespace default 
  --sync-policy automated

Once created, we checked the application status:

argocd app get gitops-demo2

Step 4: Syncing Deployments Automatically

By default, ArgoCD detects changes and applies them. However, we can also manually sync changes:

argocd app sync gitops-demo2

This ensures the application is always in sync with the declared Git state.

Testing the GitOps Workflow

1️⃣ Making a Change in GitHub

We modified public/index.html:

Welcome to GitOps Deployment!

Changed to:

GitOps Deployment with ArgoCD 🚀

After committing and pushing the changes to GitHub, ArgoCD automatically detected the update and deployed the latest version.

2️⃣ Verifying the Update

To verify the updated application, we used port forwarding:

kubectl port-forward svc/gitops-demo-service 9090:80 -n default

Then accessed the application at:

http://localhost:9090

✅ The new heading reflected the GitHub change, confirming that GitOps was successfully implemented! 🎉

Key Takeaways & Benefits of GitOps

Immutable, Version-Controlled Infrastructure

Every change is logged in Git, making rollbacks easy and maintaining full transparency.

Continuous & Automated Deployments

No manual intervention is required—ArgoCD continuously syncs changes.

Improved Security & Compliance

Git-based approval workflows ensure that only reviewed changes are deployed.

Challenges and Solutions

Challenge Solution
LoadBalancer service EXTERNAL-IP pending Used kubectl port-forward for local access
ArgoCD sync delay Manually triggered sync using argocd app sync
Kubernetes not pulling latest image Forced a rollout restart using kubectl rollout restart deployment gitops-demo2 -n default

Conclusion

GitOps using ArgoCD, Kubernetes, and Helm provides an elegant way to manage infrastructure as code. By adopting GitOps principles, we achieved a fully automated, version-controlled, and reliable deployment workflow.

This project demonstrated how GitHub commits trigger automatic updates in a Kubernetes cluster with minimal manual intervention. As organizations scale, adopting GitOps can significantly improve deployment velocity, reliability, and security.

🚀 Try implementing GitOps in your projects and experience seamless deployments!

Have questions or feedback? Drop a comment below!