Skip to main content

GitOps architecture


Table of Contents

  1. Components of a GitOps architecture
  2. Deployment flow
  3. Architecture patterns
  4. Multi-cluster
  5. High availability
  6. Hands-on exercises

1 - Components of a GitOps architecture

Overview

Key components

ComponentRoleExamples
GitOps ControllerReconciliationArgo CD, Flux
Git RepositorySource of truthGitHub, GitLab
Image RegistryImage storageDocker Hub, ECR, GCR
Secrets ManagerSecrets managementVault, Sealed Secrets
CI PipelineBuild and testsGitHub Actions, Jenkins

The GitOps Controller

🔝 Back to table of contents


2 - Deployment flow

Complete workflow

Detailed steps

# 1. Développeur pousse du code
git push origin feature/new-api

# 2. CI Pipeline se déclenche
- Build de l'application
- Tests unitaires et intégration
- Build de l'image Docker
- Push vers le registry

# 3. CI met à jour le repo GitOps
yq -i '.spec.template.spec.containers[0].image = "myapp:sha123"' \
gitops-repo/apps/myapp/deployment.yaml
git commit && git push

# 4. GitOps Agent détecte le changement
# (ArgoCD/Flux poll toutes les 3 minutes par défaut)

# 5. Agent applique les changements
kubectl apply -f deployment.yaml

# 6. Kubernetes tire l'image et déploie

Repository separation

RepositoryContentAccess
App SourceApplication codeDevelopers
GitOps ConfigK8s manifestsPlatform team
Helm ChartsShared chartsPlatform team

🔝 Back to table of contents


3 - Architecture patterns

Pattern 1: Monorepo

gitops-monorepo/
├── apps/
│ ├── frontend/
│ ├── backend/
│ └── worker/
├── infrastructure/
│ ├── monitoring/
│ └── ingress/
└── environments/
├── dev/
├── staging/
└── prod/
ProsCons
Unified viewComplex permissions
Atomic commitsLarge repo
Clear dependenciesSlower CI/CD

Pattern 2: Polyrepo

# Repos séparés
org/gitops-apps
org/gitops-infra
org/gitops-monitoring
org/gitops-env-prod
org/gitops-env-staging
ProsCons
Fine-grained permissionsFragmented view
Fast CI/CDComplex coordination
Autonomous teamsPossible duplication

Pattern 3: App of Apps

# apps/root-app.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: root-app
spec:
source:
path: apps
destination:
namespace: argocd
---
# apps/frontend.yaml, backend.yaml, etc.
# Chaque fichier est une Application ArgoCD

🔝 Back to table of contents


4 - Multi-cluster

Hub-spoke architecture

Multi-cluster ArgoCD configuration

# Enregistrer un cluster
apiVersion: v1
kind: Secret
metadata:
name: prod-cluster
labels:
argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
name: prod-cluster
server: https://prod-cluster.example.com
config: |
{
"bearerToken": "...",
"tlsClientConfig": {
"insecure": false,
"caData": "..."
}
}
# Application ciblant un cluster spécifique
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp-prod
spec:
destination:
server: https://prod-cluster.example.com
namespace: default

ApplicationSet for multi-cluster

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp
spec:
generators:
- list:
elements:
- cluster: dev
url: https://dev.example.com
- cluster: staging
url: https://staging.example.com
- cluster: prod
url: https://prod.example.com
template:
metadata:
name: 'myapp-{{cluster}}'
spec:
destination:
server: '{{url}}'
namespace: default
source:
path: 'apps/myapp/overlays/{{cluster}}'

🔝 Back to table of contents


5 - High availability

ArgoCD HA

# Installation HA
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/ha/install.yaml

# Composants HA :
# - 3 replicas argocd-server
# - 3 replicas argocd-repo-server
# - 3 replicas argocd-application-controller (avec sharding)
# - Redis HA

Considerations

ComponentHA Strategy
Git RepoNative GitHub/GitLab HA
ArgoCD ServerMultiple replicas + LB
ControllerSharding per cluster
RedisRedis Sentinel/Cluster

Disaster Recovery

# Backup ArgoCD
argocd admin export > backup.yaml

# Restore
argocd admin import < backup.yaml

# Backup Git = le repo lui-même
git clone --mirror [email protected]:org/gitops-repo.git

🔝 Back to table of contents


6 - Hands-on exercises

Quiz

Q1. What are the two types of repositories in a GitOps architecture?

Answer
  1. App Source Repository: Contains the application code
  2. GitOps Config Repository: Contains the declarative Kubernetes manifests

Q2. What is the "App of Apps" pattern?

Answer

A "root" ArgoCD Application that deploys other ArgoCD Applications. It allows managing all applications from a single entry point.

Exercise: Architecture design

Design the GitOps architecture for:

  • 10 microservices
  • 3 environments
  • 2 production clusters (for HA)
Suggested solution
gitops-repo/
├── apps/
│ ├── service1/
│ │ ├── base/
│ │ └── overlays/
│ │ ├── dev/
│ │ ├── staging/
│ │ └── prod/
│ └── ... (10 services)
├── infrastructure/
└── applicationsets/
└── all-services.yaml # ApplicationSet pour multi-cluster

Use ApplicationSet to automatically deploy to the 2 production clusters.

🔝 Back to table of contents


Key takeaways

  • Components: GitOps Controller, Git Repo, Image Registry, Secrets Manager
  • Separate App Source and GitOps Config repos
  • Patterns: Monorepo, Polyrepo, App of Apps
  • Multi-cluster: Hub-spoke architecture, ApplicationSet
  • HA: Replicas, sharding, Redis Sentinel

🔝 Back to table of contents


← Previous chapter | Next chapter: GitOps tools →