ArgoCD and Kustomize Deployment Guide 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.

🚀 Deployment Workflow

1. Build and Push Docker Image

On every push to main that passes Go Backend Tests, .github/workflows/backend-k8s-deploy.yml builds a linux/arm64 image (the cluster runs on Raspberry Pis), pushes ghcr.io/waynecheah/backend:<short-sha> and commits that tag to the production overlay. By hand:

2. Update Kustomize Overlays

Instead of editing raw YAML files, we update the kustomization.yaml in the appropriate overlay. Example: Updating Production Image
Example: Updating Production Config Edit backend/go/k8s/overlays/production/kustomization.yaml to update configMapGenerator values. Keep it in step with backend/go/fly.toml.

3. Deploy with ArgoCD

ArgoCD is configured to track the backend/go/k8s/overlays/{env} paths.
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 automatically (backend-prod has automated sync with prune and self-heal).

🛠 Manual Sync and Validation

To manually sync or preview changes:

🔐 Secrets Management

For production security:
  • Sealed Secrets: Encrypted secrets stored in Git (recommended).
  • External Secrets: Fetching from Cloud Secret Managers.

📊 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.