fluxcd / flux2

Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
https://fluxcd.io
Apache License 2.0
6.43k stars 595 forks source link

Flux cant detect helmrelease depency chart updates #3432

Closed pdeva closed 1 year ago

pdeva commented 1 year ago

Describe the bug

currently HelmRelease has no way of specifying depency on another Helm Chart (not HelmRelease). Here is what I mean.

Steps to reproduce

Create a helm chart with Chart.yaml like this:

apiVersion: v2
name: test-app
version: 1.0.0
appVersion: "1"
dependencies:
  - name: service-common
    version: "~1.0.0"
    repository: "file://../../libs/service-common"

This chart has a dependency on another chart service-common. Its a common pattern in helm charts to use other 'library' charts. Flux's HelmRelease has no way of specifying depency on another library chart. If i update the code in service-common (which is in the same git repo) this chart (test-app) will not be updated.

Expected behavior

Updating code of service-common chart should update the test-app chart too.

Screenshots and recordings

No response

OS / Distro

Linux

Flux version

0.38.1

Flux check

N/A

Git provider

No response

Container Registry provider

No response

Additional context

No response

Code of Conduct

hiddeco commented 1 year ago

This is by design, by default a HelmChart is only rebuild on version changes in the Chart.yaml. This can be changed to for every Git revision by configuring the reconcileStrategy to Revision. See https://fluxcd.io/flux/components/source/helmcharts/#reconcile-strategy for more information.

pdeva commented 1 year ago

@hiddeco so i actually do have the reconcileStrategy set to revision. Here is my code:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: test-app
  namespace: default
spec:
  interval: 1m
  chart:
    spec:
      chart: "./infra/k8s/charts/apps/test-app"
      interval: 1m
      reconcileStrategy: Revision
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system

This only picks up changes to the chart itself, which is located in ./infra/k8s/charts/apps/test-app path. However, the dependent chart is located at ./infra/k8s/charts/libs/service-common. It doesnt pick up changes to anything in that lib, which obviously cause chart.spect.chart only allows a single path to be monitored for changes.

Which is why I mentioned there needs to be additional attributes to monitor paths of dependent charts.

hiddeco commented 1 year ago

This only picks up changes to the chart itself, which is located in ./infra/k8s/charts/apps/test-app path. However, the dependent chart is located at ./infra/k8s/charts/libs/service-common. It doesnt pick up changes to anything in that lib, which obviously cause chart.spect.chart only allows a single path to be monitored for changes.

This is simply not how it works, as it does not monitor the path for changes but rather looks at the revision of the GitRepository. When this changes, a new chart is build, including any references relative to the chart directory at that Git revision.

---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: GitRepository
metadata:
  name: charts
  namespace: flux-system
spec:
  interval: 1m0s
  url: https://github.com/hiddeco/chart-revision-test
  ref:
    branch: main
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: dummy
  namespace: default
spec:
  interval: 1m0s
  chart:
    spec:
      chart: "./charts/dummy"
      interval: 1m0s
      reconcileStrategy: Revision
      sourceRef:
        kind: GitRepository
        name: charts
        namespace: flux-system

Overtime produces

Events:
  Type    Reason                 Age   From               Message
  ----    ------                 ----  ----               -------
  Normal  ChartPackageSucceeded  100s  source-controller  packaged 'dummy' chart with version '0.1.0+d7eb8f778c56'
  Normal  ArtifactUpToDate       40s   source-controller  artifact up-to-date with remote revision: '0.1.0+d7eb8f778c56'
  Normal  ChartPackageSucceeded  1s    source-controller  packaged 'dummy' chart with version '0.1.0+440cc2f08d05'

Where 0.1.0+d7eb8f778c56 is the chart for commit https://github.com/hiddeco/chart-revision-test/commit/d7eb8f778c565bd2cc84b19504f993b8b4494ece, and 0.1.0+440cc2f08d05 is the chart for commit https://github.com/hiddeco/chart-revision-test/commit/440cc2f08d056167109f5241f57221c5fcca4bb1 with a change outside of the specified chart path.

pdeva commented 1 year ago

ah got it. thank you for clarifying.