Skip to content

GitOps Repository Structure Design: Combining Helm and Kustomize, the Apps-in-App Pattern

Interactive Diagram

새 탭 ↗

In GitOps, repository structure is not merely a matter of file placement. How chart versions are managed, how configuration is separated by cluster, and how ArgoCD Applications themselves are managed declaratively are all reflected in the repository structure. This article covers a design for managing a cluster completely declaratively through a Helm + Kustomize combination and the Apps-in-App pattern.

Cluster Management: GitOps for Cluster Installation Too

Section titled “Cluster Management: GitOps for Cluster Installation Too”
PlantUML Diagram

Core principles:

  • Use Argo CD to configure every component required for cluster installation.
  • Manage installation manifests in a Git repository.
  • Perform installation through ArgoCD application sync.
  • Do not install directly on the cluster with kubectl apply: manual installations leave no history and are difficult to recover.

Git Manifests Structure: Combining Helm and Kustomize

Section titled “Git Manifests Structure: Combining Helm and Kustomize”
PlantUML Diagram

Structure overview:

  • Manage Helm charts in version-specific folders: rather than using a Helm repository, manage chart source directly in Git. When a version is needed, copy the folder to freeze that chart.
  • Kustomize runs Helm templates: Argo CD first runs kustomize build, and Kustomize invokes helm template.
  • Put cluster-specific configuration in Kustomize values.yaml: leave the base chart unchanged and keep only the differing settings for each cluster in overlay values.
  • Include the common folder as a base: place resources shared by every component, such as TLS certificates, in common and reference it as a Kustomize base.

ArgoCD Apps-in-App: Manage Applications Themselves in Git

Section titled “ArgoCD Apps-in-App: Manage Applications Themselves in Git”
PlantUML Diagram

Argo CD UI showing a parent applications Application managing four child Applications in the app of apps pattern Source: Argo CD docs, Cluster Bootstrapping, The Argo Authors, Apache-2.0

Apps-in-App pattern:

  • ArgoCD Applications can be created through the UI or CLI, but use Apps-in-App to manage the Applications themselves in a Git repository.
  • argocd-app-init is responsible for creating the other ArgoCD Applications.
  • This makes ArgoCD Applications quick to recover: syncing only argocd-app-init automatically creates the remaining Applications.
  • Directoryplatform-cluster-deploy/
    • Directorybase/
      • Directoryapps/
        • Directorypython-backend-v1.0.0/
          • …
        • Directoryspringboot-backend-v1.0.0/
          • …
        • Directoryspringboot-module-v1.0.0/
          • …
      • Directoryjobs/
        • Directoryjob-v1.0.0/
          • …
      • Directorypvcs/
        • Directorypvc-v1.0.0/
          • …
    • Directorytemplate/
      • Directoryproject/
        • Directoryapps/
          • …
        • Directoryjobs/
          • …
        • Directorypvcs/
          • …
    • Directoryprod-cluster/
      • Directoryproject-a/
        • Directoryapps/
          • …
        • Directoryjobs/
          • …
        • Directorypvcs/
          • …

Structural principles:

  • The base folder manages chart files and organizes folders by chart version.
  • The template folder is configured to use a specific (final) version from base and is used for the actual deployment files.
  • Cluster-specific folders distinguish the clusters being deployed to.
  • Organize folders in the form cluster - project - apps/pvcs/jobs.
  • Keep the subdirectory structures of the cluster and template folders aligned to prevent relative-path errors.
  • Directoryplatform-cluster-init/
    • Directorybase/
      • Directoryargo/argo-workflows-v0.8.1/
        • …
      • Directoryargocd/argo-cd-v3.26.5/
        • …
      • Directorygitea/gitea-v4.1.1/
        • …
      • Directoryharbor/harbor-v1.7.3/
        • …
      • Directorycommon/
        • …
    • Directoryprod-cluster/
      • Directoryargo/argo-workflows-v0.8.1/
        • …
      • Directoryargocd/argo-cd-v3.26.5/
        • …
      • Directorygitea/gitea-v4.1.1/
        • …
      • Directoryharbor/harbor-v1.7.3/
        • …
      • Directorycommon/
        • …

Role of the Initialize Repository:

  • Deploy the CI/CD tools and shared resources needed for initial cluster configuration.
  • The base folder is managed by chart version, while cluster-specific folders select the charts to deploy to their respective clusters.
PlantUML Diagram

This repository structure addresses chart version freezing, separation of cluster-specific configuration, and declarative Application management. When adding a new cluster, copy only the cluster folder and sync argocd-app-init to reproduce the entire environment.