Contents
Argo CD: GitOps, Terraform and Helm for Microservices (Part 1)

Argo CD: When a New Deployment Does Not Have to Be Russian Roulette

Friday, 4:30 p.m. A colleague pushes a new version of the payment service. CI passes. Deployment completes. Five minutes later, support calls: “Customers cannot pay.”

Sound familiar? It does to me. That is why I came to appreciate Argo CD: it can turn deployment from an adrenaline rush into a boring, predictable process. That is exactly what you want.

The problem: deployment without a safety net

A conventional CI/CD pipeline in many teams looks like this:

Developer → Push → CI Build → Docker Image → kubectl apply → 🤞 Pray

What happens when something fails?

bash
# Panic mode
kubectl rollout undo deployment/payment-service    # Will this work?
kubectl set image deployment/payment-service ...    # Which version was running before?
ssh production-server "docker run old-image..."     # Who does this in 2026?!

Problems with this approach:

  • ❌ Nobody knows the exact state before deployment
  • ❌ kubectl rollout undo only undoes the last rollout; what if you need to go back three versions?
  • ❌ No audit trail of who deployed what and when
  • ❌ Manual cluster changes create configuration drift

The solution: GitOps with Argo CD

Argo CD implements four GitOps principles:

1

Declarative configuration:

the system state lives in Git as YAML.
2

Git as the single source of truth:

every change has an author, timestamp and commit message.
3

Automatic application:

approved changes are deployed without manual intervention.
4

Continuous reconciliation:

a controller detects and corrects drift.

How does it work in practice?

┌─────────────┐     ┌──────────────┐     ┌─────────────────┐
│  Developer   │────▶│  Git Repo    │────▶│    Argo CD      │
│  (push)      │     │  (manifests) │     │  (controller)   │
└─────────────┘     └──────────────┘     └────────┬────────┘
                                                   │
                                                   ▼
                                          ┌─────────────────┐
                                          │   Kubernetes     │
                                          │   Cluster        │
                                          │                  │
                                          │ Desired State    │
                                          │ = Git State      │
                                          └─────────────────┘

Argo CD runs in your Kubernetes cluster as a set of controllers. It polls Git repositories or listens for webhooks, compares manifests with the live cluster and reports sync status. If something differs, it corrects it.

Terraform: infrastructure under control

Before Argo CD, you need infrastructure. Terraform makes sure the Kubernetes cluster exists and Argo CD is installed.

Kubernetes cluster and Argo CD with Terraform

hcl
# terraform/main.tf

# 1. Kubernetes cluster (AWS EKS example)
module "eks" {
  source          = "terraform-aws-modules/eks/aws"
  version         = "~> 20.0"

  cluster_name    = "production-cluster"
  cluster_version = "1.29"

  vpc_id     = module.vpc.vpc_id
  subnet_ids = module.vpc.private_subnets

  eks_managed_node_groups = {
    default = {
      instance_types = ["t3.large"]
      min_size       = 2
      max_size       = 5
      desired_size   = 3
    }
  }
}

# 2. Argo CD through the Helm provider
resource "helm_release" "argocd" {
  name             = "argocd"
  repository       = "https://argoproj.github.io/argo-helm"
  chart            = "argo-cd"
  version          = "7.7.5"
  namespace        = "argocd"
  create_namespace = true

  set {
    name  = "server.service.type"
    value = "LoadBalancer"
  }

  set {
    name  = "configs.params.server\\.insecure"
    value = "false"
  }

  depends_on = [module.eks]
}

# 3. Register the Git repository with manifests
resource "kubectl_manifest" "argocd_repo" {
  yaml_body = <<-YAML
    apiVersion: v1
    kind: Secret
    metadata:
      name: platform-repo
      namespace: argocd
      labels:
        argocd.argoproj.io/secret-type: repository
    stringData:
      url: https://github.com/your-org/k8s-manifests.git
      username: argocd-bot
      password: ${var.github_token}
  YAML

  depends_on = [helm_release.argocd]
}

Terraform handles infrastructure. Argo CD handles applications. A clear division of responsibility.

Helm: templates for microservices

Each microservice has a Helm chart. Instead of copying YAML files for each service, you use one template with different values.

A universal Helm chart for a microservice

yaml
# helm/microservice/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.name }}
  labels:
    app: {{ .Values.name }}
    version: {{ .Values.image.tag }}
spec:
  replicas: {{ .Values.replicas | default 2 }}
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0        # Never lose capacity
      maxSurge: 1              # At most one extra pod
  selector:
    matchLabels:
      app: {{ .Values.name }}
  template:
    metadata:
      labels:
        app: {{ .Values.name }}
        version: {{ .Values.image.tag }}
    spec:
      containers:
        - name: {{ .Values.name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          ports:
            - containerPort: {{ .Values.port | default 8080 }}
          readinessProbe:
            httpGet:
              path: {{ .Values.healthCheck | default "/health" }}
              port: {{ .Values.port | default 8080 }}
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: {{ .Values.healthCheck | default "/health" }}
              port: {{ .Values.port | default 8080 }}
            initialDelaySeconds: 15
            periodSeconds: 20
          resources:
            requests:
              cpu: {{ .Values.resources.requests.cpu }}
              memory: {{ .Values.resources.requests.memory }}
            limits:
              cpu: {{ .Values.resources.limits.cpu }}
              memory: {{ .Values.resources.limits.memory }}

Values for a specific microservice

yaml
# environments/production/payment-service.yaml
name: payment-service
replicas: 3

image:
  repository: registry.your-org.com/payment-service
  tag: "2.4.1"     # ← THIS changes on release

port: 8080
healthCheck: /actuator/health

resources:
  requests:
    cpu: "500m"
    memory: "512Mi"
  limits:
    cpu: "1000m"
    memory: "1Gi"

In the next part, we will connect everything with an Argo CD Application, look at rollback in practice and manage 20+ microservices using the App of Apps pattern.

All articles