ArgoCD and Kustomize Deployment Guide This document provides a detailed walkthrough for deploying the backend application using ArgoCD and Kustomize for a robust, multi-environment GitOps workflow.

📋 Prerequisites

  • Kubernetes cluster (v1.24+)
  • ArgoCD installed in the cluster
  • Docker registry access (e.g., Docker Hub, AWS ECR)
  • Kustomize (built into kubectl)
  • Git repository access with the monorepo

🏗 Directory Structure

Our deployment is organized using Kustomize overlays to manage different environments while keeping the base configuration DRY.
backend/k8s/
├── base/             # Shared base manifests (deployment.yaml, service.yaml)
└── overlays/         # Environment-specific overrides
    ├── development/  # Dev config (auto-sync)
    ├── uat/          # UAT config (auto-sync)
    ├── staging/      # Staging config (manual approval)
    └── production/   # Prod config (manual sync only)

🚀 Deployment Workflow

1. Build and Push Docker Image

Build your image and push it to your registry using environment-specific tags:
# Build for development
docker build -t [YOUR-REGISTRY]/backend:dev-latest .
docker push [YOUR-REGISTRY]/backend:dev-latest

# Build for production (use semantic versioning)
docker build -t [YOUR-REGISTRY]/backend:v1.2.3 .
docker push [YOUR-REGISTRY]/backend:v1.2.3

2. Update Kustomize Overlays

Instead of editing raw YAML files, we update the kustomization.yaml in the appropriate overlay. Example: Updating Production Image
cd backend/k8s/overlays/production
kustomize edit set image [YOUR-REGISTRY]/backend:v1.2.3
Example: Updating Dev Config Edit backend/k8s/overlays/development/kustomization.yaml to update configMapGenerator values.

3. Deploy with ArgoCD

ArgoCD is configured to track the backend/k8s/overlays/{env} paths.
# Apply the ArgoCD Application definition
kubectl apply -f backend/argocd/application.yaml
Once the application is created, ArgoCD will:
  1. Detect changes in your Git repository.
  2. Apply the Kustomize build result to the cluster.
  3. Sychnronize according to the environment policy (Auto for Dev/UAT, Manual for Prod).

🛠 Manual Sync and Validation

To manually sync or preview changes:
# Preview the Kustomize build result locally
kubectl kustomize backend/k8s/overlays/production

# Sync via ArgoCD CLI
argocd app sync backend-prod

🔐 Secrets Management

For production security:
  • Sealed Secrets: Encrypted secrets stored in Git (recommended).
  • External Secrets: Fetching from Cloud Secret Managers.
Note: In dev and uat, we use Kustomize secretGenerator for convenience, but these should not be committed to public repositories.

📊 Monitoring

  • Health Checks: Liveness and readiness probes are configured in the base deployment.
  • Metrics: Exposed at :8080/metrics for Prometheus scraping.

Summary

By leveraging ArgoCD and Kustomize, we achieve a scalable and repeatable deployment process that ensures configuration consistency across all development stages.