Skip to content

Conversation

@kvaps
Copy link

@kvaps kvaps commented Nov 18, 2025

Another implementation of fluxcd/source-controller#1931 but for source-watcher

# Example of using source-watcher with automatic symlink resolution
# 
# Suppose your GitRepository cozy-git has the following structure:
# packages/
#   apps/
#     virtual-machine/
#       Chart.yaml
#       templates/
#       values.yaml
#   library/
#     cozy-lib/
#       Chart.yaml
#       templates/
#       ...
#   apps/
#     tenant/
#       charts/
#         cozy-lib -> ../../../library/cozy-lib  (symlink)
#
# source-watcher will automatically resolve the symlink and include cozy-lib content in the artifact
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: cozy-git
  namespace: cozy-public
spec:
  interval: 1m0s
  ref:
    tag: v0.37.5
  timeout: 60s
  url: https://github.com/cozystack/cozystack.git
  ignore: |
    # exclude all
    /*
    # include packages dir
    !/packages

---
# ArtifactGenerator will create ExternalArtifact with resolved symlinks
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
  name: virtual-machine-chart
  namespace: tenant-user
spec:
  sources:
    - alias: cozy-git
      kind: GitRepository
      name: cozy-git
      namespace: cozy-public
  artifacts:
    - name: virtual-machine-chart
      # Copy chart, including all symlinks (which will be automatically resolved)
      copy:
        - from: "@cozy-git/packages/apps/virtual-machine/**"
          to: "@artifact/"
        # If there are symlinks inside virtual-machine, they will also be resolved
        # For example, if there is cozy-lib -> ../../library/cozy-lib,
        # the content of library/cozy-lib will be included in the artifact

---
# HelmRelease uses ExternalArtifact instead of direct GitRepository
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: virtual-machine-asd2
  namespace: tenant-user
spec:
  interval: 5m
  targetNamespace: cozy-system
  chart:
    spec:
      chart: "./"  # Root of the artifact (where Chart.yaml is located)
      sourceRef:
        kind: ExternalArtifact  # Use ExternalArtifact instead of GitRepository
        name: virtual-machine-chart
        namespace: tenant-user
      version: '>= 0.0.0-0'
  install:
    remediation:
      retries: -1
  upgrade:
    remediation:
      retries: -1
  values:
    cloudInit: ""
    cloudInitSeed: ""
    external: false
    externalMethod: PortList
    externalPorts:
    - 22
    instanceProfile: ubuntu
    instanceType: u1.medium
    running: true
    systemDisk:
      image: ubuntu
      storage: 5Gi
      storageClass: replicated

@kvaps
Copy link
Author

kvaps commented Nov 18, 2025

All right I was able to make it working this way:

---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: cozy-git
  namespace: cozy-public
spec:
  interval: 1m0s
  ref:
    tag: v0.37.6
  timeout: 60s
  url: https://github.com/cozystack/cozystack.git
  ignore: |
    # exclude all
    /*
    # include packages dir
    !/packages

---
# ArtifactGenerator with explicit copy operations (no symlinks needed)
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
  name: apps
  namespace: cozy-public
spec:
  sources:
    - alias: cozy-git
      kind: GitRepository
      name: cozy-git
      namespace: cozy-public
  artifacts:
    - name: apps-virtual-machine
      copy:
        - from: "@cozy-git/packages/apps/virtual-machine/**"
          to: "@artifact/virtual-machine/"
        - from: "@cozy-git/packages/library/cozy-lib/**"
          to: "@artifact/virtual-machine/charts/cozy-lib/"
    - name: apps-vm-instance
      copy:
        - from: "@cozy-git/packages/apps/vm-instance/**"
          to: "@artifact/vm-instance/"
        - from: "@cozy-git/packages/library/cozy-lib/**"
          to: "@artifact/vm-instance/charts/cozy-lib/"

---
# HelmRelease uses ExternalArtifact
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: virtual-machine-asd2
  namespace: tenant-user
spec:
  interval: 5m
  chartRef:
    kind: ExternalArtifact
    name: apps-virtual-machine
    namespace: cozy-public
  install:
    remediation:
      retries: -1
  upgrade:
    remediation:
      retries: -1
  values:
    cloudInit: ""
    cloudInitSeed: ""
    external: false
    externalMethod: PortList
    externalPorts:
    - 22
    instanceProfile: ubuntu
    instanceType: u1.medium
    running: true
    systemDisk:
      image: ubuntu
      storage: 5Gi
      storageClass: replicated

Seems I can even generate charts from the bundled OCI repository.
Cool tool folks, thank you.

The sad thing is automatically generated index for the repository, but this can be handled by code generation.

I will close this PR for now, as original issue closed. I have no more time for testing it right now.

@kvaps kvaps closed this Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant