Platform Engineering GitOps & CI/CD 24/7 SRE Support
+91 86790 05791 hello@webkaryon.com Rampur, UP, India · Global Remote
GitOps 5 min read

Argo CD app-of-apps without the sprawl

The app-of-apps pattern is the first thing most teams reach for and the first thing that becomes unmanageable. Here is the structure we use instead once a platform passes roughly twenty services.

App-of-apps works beautifully for a demo and acceptably for ten services. Somewhere past twenty, the root application becomes a file that everybody edits and nobody understands, and sync waves start producing ordering bugs that only appear in production.

Generate applications, do not write them

The fix is ApplicationSet with a Git generator. Teams add a directory; the Application appears. Nobody edits a central file, so nobody has merge conflicts in one.

bootstrap/production.yaml yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: production-services
  namespace: argocd
spec:
  goTemplate: true
  generators:
    - git:
        repoURL: https://github.com/acme/platform-config
        revision: main
        directories:
          - path: applications/*/overlays/production
  template:
    metadata:
      name: '{{index .path.segments 1}}-production'
    spec:
      project: production
      source:
        repoURL: https://github.com/acme/platform-config
        targetRevision: main
        path: '{{.path.path}}'
      destination:
        server: https://kubernetes.default.svc
        namespace: '{{index .path.segments 1}}'
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true

Projects as the permission boundary

An AppProject per environment restricts which repositories, destinations and resource kinds are allowed. This is what stops a mistake in a team's overlay from creating a ClusterRole.

bootstrap/projects/production.yaml yaml
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: production
spec:
  sourceRepos:
    - https://github.com/acme/platform-config
  destinations:
    - server: https://kubernetes.default.svc
      namespace: '!kube-system'
  clusterResourceWhitelist: []        # teams get namespace scope only
  namespaceResourceBlacklist:
    - group: ''
      kind: ResourceQuota
    - group: rbac.authorization.k8s.io
      kind: ClusterRoleBinding

Sync waves only where ordering is real

Sync waves are tempting and overused. Ordering should be expressed in the application, readiness probes, retries, migrations that tolerate the old schema, not in the deployment tool. We reserve waves for genuine infrastructure prerequisites: CRDs before the controllers that use them.

What we actually use waves for

  • Wave -2: namespaces, quotas and network policy
  • Wave -1: CRDs and cluster-scoped prerequisites
  • Wave 0: everything else, concurrently
  • Nothing beyond wave 1 without a written reason

Watching for the drift you want to know about

weekly drift report
argocd app list -o json | jq -r '.[] | select(.status.sync.status!="Synced") | .metadata.name'
search-production
notifications-production

argocd app diff search-production
===== apps/Deployment search =====
-   replicas: 6
+   replicas: 14

# scaled by hand during Friday's traffic spike, never committed

That diff is a conversation, not an incident. Somebody solved a real problem under pressure; the job now is to get the fix into Git and work out why autoscaling did not handle it.

Arjun has spent twelve years building delivery systems, most of them on Kubernetes and most of them inherited from someone else. He writes about the parts that are harder than the documentation suggests.

Keep reading

Related field notes