Cloud Engineer & GCP Engineer: Structuring GitOps Repositories with Helm & ArgoCD for Multi-Environment Kubernetes
When teams manage Google Kubernetes Engine (GKE) or Amazon EKS clusters by running ad-hoc helm upgrade commands from engineer laptops or copying entire YAML manifests across dev/, staging/, and prod/ branches, configuration drift and accidental production overwrites become inevitable. As a Cloud Engineer and GCP Engineer, I architect trunk-based GitOps repositories paired with ArgoCD ApplicationSets, strict schema validation, and environment-specific Helm value overlays.
1. Trunk-Based Directory Layout Separation: Base Charts vs. Environment Value Overlays
Never use long-lived Git branches (`git checkout prod`) to represent environments—branch divergence makes it impossible to diff what is running in staging versus production. Instead, a single trunk (`main`) separates immutable chart templates (`charts/`) from environment-specific value overrides (`environments/{env}/values.yaml`):
# ArgoCD ApplicationSet generating dev, staging, and prod deployments from a single trunk
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: core-api-environments
namespace: argocd
spec:
generators:
- list:
elements:
- env: staging
cluster: https://kubernetes.default.svc
namespace: afcom-staging
replicas: "2"
- env: prod
cluster: https://gke-prod-control-plane.internal
namespace: afcom-prod
replicas: "6"
template:
metadata:
name: "core-api-{{env}}"
spec:
project: default
source:
repoURL: https://github.com/org/k8s-gitops-manifests.git
targetRevision: main
path: charts/core-api
helm:
valueFiles:
- values.yaml
- "../../environments/{{env}}/core-api-values.yaml"
destination:
server: "{{cluster}}"
namespace: "{{namespace}}"
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
2. CI Pre-Merge Validation (`helm template` + `kubeconform`) & Immutable Image Digests
In CI, every pull request renders `helm template` for all environments and validates the resulting manifests against strict Kubernetes JSON schemas using `kubeconform -strict` before ArgoCD ever syncs the cluster. Application CI pipelines commit immutable container SHA-256 digests (`image.tag: sha256:...`) into the GitOps repository—aligning with our Docker, Kubernetes & Helm production guide and Cloud Engineer multi-region AWS & GCP architecture.
Need a Cloud Engineer or GCP Engineer to structure your Kubernetes, Helm, and ArgoCD GitOps workflows? Book a 1-Day Engineering Sprint.