This repo collects some patterns (AKA strategies, models, approaches, best practices, etc.) about GitOps process design (AKA GitOps repository structures, etc.) as well as links to talks, articles and example repos.
It originated in schnatterer's talk about the "perfect" GitOps process, our experience in consulting, and our GitOps trainings for both Flux and ArgoCD.
For questions or suggestions you are welcome to join us at our community forum.
PRs welcome!
- Pattern areas
- GitOps Patterns
- Operator deployment
- Repository structure
- Promotion
- Wiring
- Bootstrapping
- Linking, includes Nesting (e.g. App of Apps), Templating
- Public GitOps Repo Examples
- Synonyms
- References
Let's categorize GitOps patterns into separate areas to make them easier to grasp.
- Operator deployment: GitOps operators ↔ Clusters/Namespaces
- Repository: How many repos?
- Promotion:
- Environments: How to model environments/stages?
- Implementation: How to implement the actual process of promotion?
- Wiring: Bootstrapping operator, linking repos and folders
- Hub and Spoke 12 1 Operator : n Clusters
- Standalone 1: 1 Operator : 1 Cluster
- Namespaced 3: n Operators : 1 Cluster
- Split-Instance 1: 1 Operator : n Clusters; components split between management and target clusters
- Monorepo 24
Opposite: polyrepo 2 - Repo per Team 4
More generalized: Team ➡️ Tenant4 - Repo per Application 24
Implementations: - Repo per environment 4
Synonym: Environment per repository6, Repo per Stage
We understand promotions as the process of deploying applications to different environments.
Sometimes, the term "promotion" is prefixed with other words: Release/Application/Environment/Workload/Change Promotion
For promotion, we see different sets of patterns:
- one regarding the modelling of environments and
- one regarding the implementation of the actual process of promotion.
- Folder/Directory per environment
Synonym: Environment per folder 6 - Repo per environment 4
Synonym: Environment per repo 6 - Branch per environment
Synonym: Environment per branch 6
Often discouraged 5 or declared an anti-pattern78, but can work 9. - Preview environments 10 11 12
Synonyms: ephemeral, dynamic, pull request13, test, temporary10
Beyond the GitOps world also known as "Preview Deployments"14 and "Deploy Previews"15
- Configuration Management
Synonyms: Templating, Patching, Overlay, Rendering- plain kustomize (
kustomize.yaml
) - Helm
- via CRD such as
HelmRelease
(Flux) orApplication
(ArgoCD) - via Umbrella Chart16
- via
helm template
on CI server
- via CRD such as
- plain kustomize (
- Global Environments vs Environment per App3
- Config update
Who updates image (version) in GitOps repo, creates branch and PR?- Manual: Human pushes branch and create PR 🥵
- Image Updater: Operator pushes branch, create PR manually
- CI Server: Build job pushes branch, creates PR
- Dependency Bot: Bot pushes branch, creates PR
- Bootstrapping ,
e.g. using
kubectl
or operator-specific CLI such asflux
orargocd-autopilot
- Linking
e.g. using Operator-specific CRDs such as
Kustomization
(Flux) orApplication
(ArgoCD)- Nesting, e.g. App of Apps pattern 17 (ArgoCD)
- Templating, e.g. implemented using
ApplicationSets
See also 3.
- Repo pattern: Per team mixed with per app
- Operator pattern: Standalone (Hub and Spoke, namespaced)
- Operator: ArgoCD (Flux)
- Boostrapping:
Helm
,kubectl
- Linking: ArgoCD
Application
- Features:
- Env per app Pattern
- Operate ArgoCD with GitOps
- Config Update via CI server
- Mixed repo patterns
- ArgoCD and Flux examples
argoproj-labs/argocd-autopilot
- Repo pattern: Monorepo
- Operator pattern: Standalone / Hub and Spoke
- Operator: ArgoCD
- Boostrapping:
argocd-autopilot
- Linking:
kustomize.yaml
, ArgoCDApplication
,ApplicationSet
- Features:
- Operate ArgoCD with GitOps
- In the future: a lot more automation and YAML creation
fluxcd/flux2-kustomize-helm-example
- Repo pattern: Monorepo
- Operator pattern: Standalone
- Operator: Flux
- Boostrapping:
flux
CLI - Linking:
kustomize.yaml
, FluxKustomization
- Features: cross-cutting infra
- Repo pattern: Repo per team/tenant
- Operator pattern: Standalone
- Operator: Flux
- Boostrapping:
flux
CLI - Linking:
kustomize.yaml
, FluxKustomization
- Features: cross-cutting infra
christianh814/example-kubernetes-go-repo
christianh814/example-kubernetes-goflux-repo
christianh814/example-openshift-go-repo
- Repo pattern: Monorepo
- Operator pattern: Standalone
- Operator: [ArgoCD] [flux]
- Boostrapping: kubectl
- Linking:
kustomize.yaml
,- ArgoCD
Application
,ApplicationSet
/ - Flux
Kustomization
- ArgoCD
- Features:
- Cross-cutting infra and app(s)
- ArgoCD and Flux examples
kostis-codefresh/gitops-environment-promotion
- Operator: ArgoCD (Flux)
- Features:
- Env variants for a single app
- Promotion "via cp"
- Patterns ≈ strategies, models, approaches, best practices, standards
- GitOps process design ≈ GitOps repository structures,
- GitOps Operator ≈ GitOps controller
- Config Repo = GitOps repo, Infra repo, Payload repo
- App repo = Source code repo, Source repo
- Environment = Stage
- Folder = Directory
- Templating ≈ Templating, Patching, Overlay, Rendering, Bundling, Packaging?
Footnotes
-
Article A Comprehensive Overview of Argo CD Architectures – 2023 by Dan Garfield ↩ ↩2 ↩3
-
Article/Book How to set up your GitOps directory structure by Christian Hernandez ↩ ↩2 ↩3 ↩4
-
Slides The perfect GitOps process: repos, folders, stages, patterns by Johannes Schnatterer ↩ ↩2 ↩3 ↩4 ↩5
-
Documentation Flux | Ways of structuring your repositories ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Talk GitOps: Core Concepts & Ways of Structuring Your Repos by Pinky Ravi and Scott Rigby ↩ ↩2
-
Lesson GitOps at Scale Lesson series - Git repository strategies by Codefresh (paywalled) ↩ ↩2 ↩3 ↩4
-
Article Stop Using Branches for Deploying to Different GitOps Environments by Kostis Kapelonis ↩
-
Article Git best practices: Workflows for GitOps deployments by Christian Hernandez ↩
-
Article Monitoring and Hardening the GitOps Delivery Pipeline with Flux by Florian Heubeck ↩
-
Article Creating Temporary Preview Environments Based On Pull Requests With Argo CD And Codefresh by Codefresh ↩ ↩2
-
Talk GitOps Con Europe - Implementing Preview Environments with GitOps in Kubernetes by François Le Pape, Remazing ↩
-
Talk Preview Environments with ArgoCD by Brandon Phillips ↩
-
Video Environments Based On Pull Requests (PRs): Using Argo CD To Apply GitOps Principles On Previews by Viktor Farcic ↩
-
Documentation Vercel: Preview Deployments ↩
-
Documentation Netlify: Deploy Previews ↩
-
Documentation Helm | Chart Development Tips and Tricks ↩
-
Documentation ArgoCD: Cluster Bootstrapping - App Of Apps Pattern ↩