The source-watcher is a GitOps toolkit controller that extends Flux with advanced source composition and decomposition patterns.
The source-watcher controller implements the ArtifactGenerator API, which allows Flux users to:
- π Compose multiple Flux sources (GitRepository, OCIRepository, Bucket) into a single deployable artifact
- π¦ Decompose monorepos into multiple independent artifacts with separate deployment lifecycles
- π― Optimize reconciliation by only triggering updates when specific paths change
- ποΈ Structure complex deployments from distributed sources maintained by different teams
- Flux v2.7.0 or later
- source-watcher v2.0.0 or later
- kustomize-controller & helm-controller with
--feature-gates=ExternalArtifact
Deploy an application that combines Kubernetes manifests from different sources:
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
name: my-app
namespace: apps
spec:
sources:
- alias: backend
kind: GitRepository
name: backend-repo
- alias: frontend
kind: OCIRepository
name: frontend-oci
- alias: config
kind: Bucket
name: config-bucket
artifacts:
- name: my-app-composite
copy:
- from: "@backend/deploy/k8s/**"
to: "@artifact/backend/"
- from: "@frontend/k8s/manifests/*.yaml"
to: "@artifact/frontend/"
- from: "@config/prod/settings.yaml"
to: "@artifact/config.yaml"
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: my-app
namespace: apps
spec:
interval: 15m
sourceRef:
kind: ExternalArtifact
name: my-app-composite
path: "./"
prune: true
Split a monorepo into independently deployable services:
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
name: platform-services
namespace: platform
spec:
sources:
- alias: monorepo
kind: GitRepository
name: platform-monorepo
artifacts:
- name: policies
copy:
- from: "@monorepo/platform/policy/**"
to: "@artifact/"
- name: auth-service
copy:
- from: "@monorepo/services/auth/deploy/**"
to: "@artifact/"
exclude: ["*.md"]
- name: api-gateway
copy:
- from: "@monorepo/services/gateway/deploy/**"
to: "@artifact/"
exclude: ["*.md", "**/charts/**"]
Each service gets its own ExternalArtifact with an independent revision.
Changes to services/auth/
only trigger the reconciliation of the auth-service,
leaving other services untouched.
Compose Helm charts with custom values from different sources:
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
name: podinfo
namespace: apps
spec:
sources:
- alias: chart
kind: OCIRepository
name: podinfo-chart
- alias: repo
kind: GitRepository
name: podinfo-values
artifacts:
- name: podinfo-composite
originRevision: "@chart"
copy:
- from: "@chart/"
to: "@artifact/"
- from: "@repo/charts/podinfo/values.yaml"
to: "@artifact/podinfo/values.yaml"
strategy: Overwrite
- from: "@repo/charts/podinfo/values-prod.yaml"
to: "@artifact/podinfo/values.yaml"
strategy: Merge
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: apps
spec:
interval: 15m
releaseName: podinfo
chartRef:
kind: ExternalArtifact
name: podinfo-composite
The generated artifacts are versioned based on the hash computed from the artifact's content. This means:
- β Identical content = same revision (no unnecessary reconciliations)
- β Any change to included content = new revision (guaranteed updates)
- β Automatic change detection across all source types
Copy operations support glob patterns, exclusions and YAML merge:
@source/file.yaml
β@artifact/dest/
- Copy file into directory@source/dir/
β@artifact/dest/
- Copy directory as subdirectory@source/dir/**
β@artifact/dest/
- Copy directory contents@source/file.yaml
β@artifact/existing.yaml
- Later copy overwrites earlier onesexclude: ["*.md"]
- Exclude matching files from copystrategy: Merge
- Deep merge YAML files instead of overwriting
- Multi-Team Collaboration - Different teams maintain different Kubernetes configurations in separate repositories. ArtifactGenerator combines them into deployable units while maintaining clear ownership boundaries.
- Environment-Specific Composition Compose base manifests with environment-specific configurations from different sources without duplicating files across repositories.
- Vendor Chart Customization - Combine upstream Helm charts from OCI registries with your organization's custom values and configuration overrides stored in Git.
- Selective Deployment - Deploy only changed components from large repositories by decomposing them into dedicated artifacts.
This project is Apache 2.0 licensed and accepts contributions via GitHub pull requests. To start contributing please see the contrib guide.