Back to Blog
GitOps

GitOps at Scale: App-of-Apps and Policy Gates

December 2024

Key Takeaways

  • App-of-apps pattern enables hierarchical GitOps management for complex multi-cluster environments
  • Policy gates (OPA, Kyverno) enforce compliance before deployments reach production
  • Multi-tenant repository structures require careful access control and promotion workflows

Introduction

GitOps has become the de facto standard for managing Kubernetes deployments, but scaling GitOps practices across multiple clusters, teams, and environments presents unique challenges. As organizations grow, simple single-repo, single-cluster setups evolve into complex multi-tenant architectures requiring sophisticated repository structures and policy enforcement.

This article explores advanced GitOps patterns for enterprise-scale deployments, focusing on app-of-apps architectures, policy gates, and promotion workflows that enable safe, auditable, and scalable operations.

The App-of-Apps Pattern

The app-of-apps pattern uses a parent ArgoCD Application to manage multiple child Applications. This creates a hierarchical structure where a root application references other applications, enabling centralized management of complex deployments.

Structure Overview

In a typical app-of-apps setup:

  • Root Application: Manages cluster-level or environment-level configurations
  • Child Applications: Individual microservices, infrastructure components, or team-owned resources
  • Source Repositories: Can be monorepos or separate repos per team/service

Benefits

  • Centralized visibility into all applications across clusters
  • Simplified bootstrap process for new clusters or environments
  • Consistent configuration management across teams
  • Easier rollback of entire environments

Implementation Example

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: root-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/org/gitops-root
    targetRevision: main
    path: environments/production
  destination:
    server: https://kubernetes.default.svc
    namespace: argocd
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Repository Structures

Monorepo Approach

All applications and configurations live in a single repository with clear directory structures:

gitops-repo/
├── environments/
│   ├── production/
│   │   ├── apps/
│   │   │   ├── app-of-apps.yaml
│   │   │   ├── frontend/
│   │   │   ├── backend/
│   │   │   └── infrastructure/
│   │   └── base/
│   └── staging/
├── applications/
│   ├── frontend/
│   ├── backend/
│   └── infrastructure/
└── base/

Pros: Single source of truth, easier cross-team collaboration, simplified access control.

Cons: Can become large and unwieldy, potential merge conflicts, slower CI/CD for large teams.

Multi-Repo Approach

Each team or service maintains its own repository:

  • Team-specific repos for application configurations
  • Central infrastructure repo for shared resources
  • Environment-specific repos for promotion workflows

Pros: Team autonomy, smaller repos, independent CI/CD pipelines.

Cons: More complex access control, potential configuration drift, harder to maintain consistency.

Policy Gates and Compliance Automation

Policy gates enforce compliance and security requirements before deployments reach production. They act as automated checkpoints in your GitOps workflow, validating configurations against organizational policies.

Open Policy Agent (OPA)

OPA provides policy-as-code capabilities for Kubernetes. Use OPA Gatekeeper to enforce policies at admission time, preventing non-compliant resources from being created.

Common policies:

  • Require resource limits on all containers
  • Enforce image pull policies and registries
  • Require security contexts and non-root users
  • Validate label requirements

Kyverno

Kyverno is a Kubernetes-native policy engine that uses YAML for policy definitions. It can validate, mutate, and generate resources.

Advantages:

  • Kubernetes-native (no external service required)
  • Can mutate resources to add required fields automatically
  • Simpler policy syntax for common use cases

ArgoCD Policy Gates

ArgoCD can integrate with external policy engines through webhooks and admission controllers. Configure sync windows and sync policies to control when deployments can occur.

Promotion Workflows

Promotion workflows move applications through environments (dev → staging → production) with appropriate approvals and validations at each stage.

Automated Promotion

Use CI/CD pipelines to automatically promote successful deployments:

  1. Merge to main branch triggers deployment to staging
  2. Automated tests run in staging environment
  3. On success, create PR to production branch or update production manifests
  4. Require manual approval for production promotion

GitOps Promotion Patterns

  • Branch-based: Different branches for each environment
  • Directory-based: Same branch, different directories per environment
  • Tag-based: Use Git tags to mark promotion points

Multi-Tenant Considerations

ArgoCD Projects

Use ArgoCD Projects to isolate teams and enforce resource restrictions:

  • Limit which namespaces teams can deploy to
  • Restrict source repositories and cluster destinations
  • Enforce RBAC policies per project

Namespace Isolation

Implement proper namespace isolation with NetworkPolicies, ResourceQuotas, and LimitRanges to prevent resource contention and security issues.

Best Practices

  • Start with a monorepo structure and evolve to multi-repo as teams grow
  • Implement policy gates early—it's harder to retrofit compliance later
  • Use automated testing in lower environments before promotion
  • Maintain clear documentation of repository structures and promotion processes
  • Implement proper RBAC and access controls from the beginning
  • Monitor sync status and application health across all clusters
  • Use Git tags or semantic versioning for reproducible deployments

Conclusion

Scaling GitOps requires careful planning of repository structures, policy enforcement, and promotion workflows. The app-of-apps pattern provides a solid foundation for managing complex multi-cluster deployments, while policy gates ensure compliance and security throughout the deployment lifecycle.

Remember that GitOps is not just about tools—it's about culture and processes. Invest in training, documentation, and gradual adoption rather than attempting a big-bang migration. Start simple, iterate, and scale as your organization's needs evolve.