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 tomain 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 thekustomization.yaml in the appropriate overlay.
Example: Updating Production Image
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 thebackend/go/k8s/overlays/{env} paths.
- Detect changes in your Git repository.
- Apply the Kustomize build result to the cluster.
- Sychnronize automatically (
backend-prodhas 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
basedeployment. - Metrics: Exposed at
:8080/metricsfor Prometheus scraping.