DEV Community

Cover image for πŸš€ GitOps Made Simple: Automating Deployments with ArgoCD & Helm
Romulo Franca
Romulo Franca

Posted on β€’ Edited on

1 1

πŸš€ GitOps Made Simple: Automating Deployments with ArgoCD & Helm

πŸ˜‚ Introduction: Why GitOps? Because CI/CD Needed a Makeover

Picture this: Your team is manually deploying apps to Kubernetes. The YAMLs are scattered, and no one knows which version is running in production. Jenkins jobs fail randomly, and rollback is a prayer-based process. Sound familiar?

Enter GitOpsβ€”the DevOps methodology that treats Git as the single source of truth for your infrastructure and applications. Instead of manually applying changes, you commit them to Git, and a tool like ArgoCD ensures your cluster stays in sync. Pair this with Helm to manage Kubernetes manifests like a pro, and you've got a rock-solid deployment strategy.

By the end of this guide, you'll:

βœ… Understand the core principles of GitOps

βœ… Set up ArgoCD for automated Kubernetes deployments

βœ… Use Helm to simplify and manage Kubernetes applications

βœ… Implement CI/CD pipelines to build, test, and scan container images

βœ… Learn how to separate application and infrastructure repositories for better modularity

So, grab your coffee β˜•, and let’s dive into automated deployments with ArgoCD, Helm, and CI/CD pipelines!


πŸ” What is GitOps? (And Why You Should Care)

πŸ“Œ GitOps in a Nutshell

GitOps is a developer-centric approach to managing infrastructure and applications using Git. It’s based on these core principles:

1️⃣ Declarative Configuration – Everything (infra, apps) is defined as code.

2️⃣ Versioned & Immutable – Git acts as the source of truth. Rollbacks are as easy as git revert.

3️⃣ Automated Syncing – A tool (like ArgoCD) ensures the actual state in Kubernetes matches the desired state in Git.

4️⃣ Continuous Reconciliation – If someone accidentally applies a change outside Git, GitOps automatically fixes it.

🎯 Why ArgoCD?

ArgoCD is a lightweight, Kubernetes-native GitOps tool that continuously monitors Git repositories and applies the desired state to your cluster.

βœ… Self-healing – If someone changes something manually, ArgoCD will fix it.

βœ… Multi-cluster support – Manage multiple clusters from a single dashboard.

βœ… Easy Rollbacks – Revert to a previous commit and ArgoCD will handle the rest.

βœ… RBAC & SSO support – Secure your deployments with fine-grained access control.


πŸ”§ Setting Up ArgoCD in Kubernetes

Before we automate anything, let’s get ArgoCD installed on our Kubernetes cluster.

πŸ”Ή Step 1: Install ArgoCD

ArgoCD runs inside Kubernetes, and installing it is as simple as:

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

Verify the installation:

kubectl get pods -n argocd
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 2: Expose the ArgoCD API Server

By default, ArgoCD runs internally. To access the UI, expose it via kubectl port-forward:

kubectl port-forward svc/argocd-server -n argocd 8080:443
Enter fullscreen mode Exit fullscreen mode

Now, open your browser and navigate to https://localhost:8080. πŸŽ‰

πŸ”Ή Step 3: Login to ArgoCD

Get the initial admin password:

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

Login using the CLI:

argocd login localhost:8080 --username admin --password <your-password>
Enter fullscreen mode Exit fullscreen mode

πŸ›  Deploying an Application with ArgoCD and Helm

Now that we have ArgoCD running, let’s deploy a sample application using Helm.

πŸ“Œ What is Helm?

Helm is a package manager for Kubernetes that simplifies deploying applications by using charts. Instead of managing hundreds of YAML files, you define parameters in values.yaml, and Helm takes care of the rest.

πŸ”Ή Step 1: Separate Your Repositories

To follow GitOps best practices, separate your repositories into:

βœ… Application Repository – Contains your app code, Dockerfile, and CI/CD pipeline for building images.

βœ… Infrastructure Repository – Contains your Helm charts, ArgoCD configurations, and Kubernetes manifests.

πŸ“‚ app-repo/
  β”œβ”€β”€ src/
  β”œβ”€β”€ Dockerfile
  β”œβ”€β”€ .github/workflows/build-and-push.yaml  # CI/CD pipeline
  β”œβ”€β”€ README.md

πŸ“‚ infra-repo/
  β”œβ”€β”€ charts/
  β”œβ”€β”€ values.yaml
  β”œβ”€β”€ applications/
  β”œβ”€β”€ argocd.yaml
  β”œβ”€β”€ README.md
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 2: CI/CD Pipeline for Building, Testing, and Scanning

Use GitHub Actions, GitLab CI, or Jenkins to:

1️⃣ Build the container image

2️⃣ Scan for vulnerabilities (Trivy, Snyk, or Clair)

3️⃣ Run tests (Unit tests, integration tests)

4️⃣ Push the image to a container registry

Example GitHub Actions Workflow (build-and-push.yaml):

name: Build and Push Docker Image

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Login to DockerHub
        run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

      - name: Build and tag Docker image
        run: |
          docker build -t my-app:latest .
          docker tag my-app:latest my-dockerhub/my-app:${{ github.sha }}

      - name: Scan image for vulnerabilities
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: 'my-dockerhub/my-app:${{ github.sha }}'
          format: 'table'

      - name: Push Docker image
        run: |
          docker push my-dockerhub/my-app:${{ github.sha }}
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 3: Configure ArgoCD to Watch Helm Chart Repo

Now, create an ArgoCD application that points to your Helm chart repository:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-helm-app
  namespace: argocd
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  project: default
  source:
    chart: my-app
    repoURL: https://github.com/example/infra-repo
    targetRevision: main
    helm:
      values: |
        image:
          repository: my-dockerhub/my-app
          tag: latest
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
Enter fullscreen mode Exit fullscreen mode

Apply the application manifest:

kubectl apply -f my-app.yaml
Enter fullscreen mode Exit fullscreen mode

πŸ” Best Practices for GitOps with ArgoCD and Helm

βœ… Separate Application & Infrastructure Repositories – Keep your app code and deployment configs independent.

βœ… Use CI/CD Pipelines – Automate image building, scanning, and testing.

βœ… Enable RBAC in ArgoCD – Restrict who can apply changes.

βœ… Use Helm Secrets or SOPS – Never store plaintext secrets in Git.

βœ… Monitor with Prometheus & Grafana – Use ArgoCD metrics for insights.

βœ… Automate Image Updates – Use ArgoCD Image Updater to pull new images.


πŸ“’ Conclusion: GitOps FTW! πŸš€

By combining ArgoCD, Helm, and CI/CD pipelines, you get:

βœ” Automated deployments

βœ” Self-healing applications

βœ” Secure & scalable pipelines

πŸ”₯ Try deploying your own apps using GitOps and let me know how it goes! πŸš€

πŸ‘‰ Next Steps:

Happy GitOps-ing! πŸŽ‰

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here β†’

Top comments (0)

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more