fluxcd / helm-controller

The GitOps Toolkit Helm reconciler, for declarative Helming
https://fluxcd.io
Apache License 2.0
414 stars 164 forks source link

Track changes in `.spec.postRenderers` #965

Closed souleb closed 6 months ago

souleb commented 6 months ago

fix #964

souleb commented 6 months ago

I have tested the last code on a kind cluster with an existing HR on v1beta2

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        1
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Post Renderers:
    Kustomize:
      Patches:
        Patch:  - op: add
  path: /metadata/annotations/hello
  value: world2

        Target:
          Kind:     Deployment
          Name:     podinfo-template
          Version:  v1
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:22:59Z
    Message:               Helm install succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2
    Observed Generation:   1
    Reason:                InstallSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
  History:
    Chart Name:      podinfo
    Chart Version:   6.6.2
    Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
    Digest:          sha256:11006d53cba942b73d124414f755869565730d24a36480b3208948c60275597d
    First Deployed:  2024-05-07T08:22:55Z
    Last Deployed:   2024-05-07T08:22:55Z
    Name:            podinfo-template
    Namespace:       default
    Status:          deployed
    Test Hooks:
      podinfo-template-grpc-test-kj0hv:
        Last Completed:  2024-05-07T08:23:02Z
        Last Started:    2024-05-07T08:23:00Z
        Phase:           Succeeded
      Podinfo - Template - Jwt - Test - Gufwh:
        Last Completed:  2024-05-07T08:23:05Z
        Last Started:    2024-05-07T08:23:02Z
        Phase:           Succeeded
      podinfo-template-service-test-aumr6:
        Last Completed:           2024-05-07T08:23:07Z
        Last Started:             2024-05-07T08:23:05Z
        Phase:                    Succeeded
    Version:                      1
  Last Attempted Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:      1
  Last Attempted Release Action:  install
  Last Attempted Revision:        6.6.2
  Observed Generation:            1
  Storage Namespace:              default
Events:
  Type    Reason            Age   From             Message
  ----    ------            ----  ----             -------
  Normal  InstallSucceeded  102s  helm-controller  Helm install succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2
  Normal  TestSucceeded     94s   helm-controller  Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully

Existing HelmRelease should adopt PostRenderers status without upgrade

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        1
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Post Renderers:
    Kustomize:
      Patches:
        Patch:  - op: add
  path: /metadata/annotations/hello
  value: world2

        Target:
          Kind:     Deployment
          Name:     podinfo-template
          Version:  v1
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:22:59Z
    Message:               Helm install succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2
 1 hr.yaml +                                                                                                                                                                                              X
    Observed Generation:   1
    Reason:                InstallSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
  History:
    Chart Name:      podinfo
    Chart Version:   6.6.2
    Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
    Digest:          sha256:11006d53cba942b73d124414f755869565730d24a36480b3208948c60275597d
    First Deployed:  2024-05-07T08:22:55Z
    Last Deployed:   2024-05-07T08:22:55Z
    Name:            podinfo-template
    Namespace:       default
    Status:          deployed
...
    Version:                             1
  Last Attempted Config Digest:          sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:             1
  Last Attempted Post Renderers Digest:  sha256:0801f4f2fec3b08c5c25664bbcba357334dfae9aa6f4d59813079749d3acc154
  Last Attempted Release Action:         install
  Last Attempted Revision:               6.6.2
  Last Handled Reconcile At:             2024-05-07T10:24:53.300426+02:00
  Observed Generation:                   1
  Storage Namespace:                     default

Change to PostRenderers should trigger an upgrade

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        2
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Post Renderers:
    Kustomize:
      Patches:
        Patch:  - op: add
  path: /metadata/annotations/hello
  value: world

        Target:
          Kind:     Deployment
          Name:     podinfo-template
          Version:  v1
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:26:38Z
    Message:               Helm test succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   2
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:26:20Z
    Message:               Helm upgrade succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2
    Observed Generation:   2
    Reason:                UpgradeSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:26:38Z
    Message:               Helm test succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   2
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
  ...
  Last Attempted Config Digest:          sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:             2
  Last Attempted Post Renderers Digest:  sha256:fd5c051933da29da53f8f5d34c5b89247b88899153b84807cda11b1b9a58f44f
  Last Attempted Release Action:         upgrade
  Last Attempted Revision:               6.6.2
  Last Handled Reconcile At:             2024-05-07T10:26:23.760449+02:00
  Observed Generation:                   2
  Storage Namespace:                     default
Events:
  Type    Reason            Age    From             Message
  ----    ------            ----   ----             -------
  Normal  InstallSucceeded  3m44s  helm-controller  Helm install succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2
  Normal  TestSucceeded     3m36s  helm-controller  Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully
  Normal  UpgradeSucceeded  23s    helm-controller  Helm upgrade succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2
  Normal  TestSucceeded     5s     helm-controller  Helm test succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2: 3 test hooks completed successfully

Removing PostRenderers should trigger an update and unset `Last Attempted Post Renderers Digest``

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        3
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:28:04Z
    Message:               Helm test succeeded for release default/podinfo-template.v3 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   3
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:27:47Z
    Message:               Helm upgrade succeeded for release default/podinfo-template.v3 with chart podinfo@6.6.2
    Observed Generation:   3
    Reason:                UpgradeSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:28:04Z
    Message:               Helm test succeeded for release default/podinfo-template.v3 with chart podinfo@6.6.2: 3 test hooks completed successfully
    Observed Generation:   3
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
...
  Last Attempted Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:      3
  Last Attempted Release Action:  upgrade
  Last Attempted Revision:        6.6.2
  Last Handled Reconcile At:      2024-05-07T10:27:52.283029+02:00
  Observed Generation:            3
  Storage Namespace:              default
Events:
  Type    Reason            Age    From             Message
  ----    ------            ----   ----             -------
  Normal  InstallSucceeded  5m13s  helm-controller  Helm install succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2
  Normal  TestSucceeded     5m5s   helm-controller  Helm test succeeded for release default/podinfo-template.v1 with chart podinfo@6.6.2: 3 test hooks completed successfully
  Normal  UpgradeSucceeded  112s   helm-controller  Helm upgrade succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2
  Normal  TestSucceeded     94s    helm-controller  Helm test succeeded for release default/podinfo-template.v2 with chart podinfo@6.6.2: 3 test hooks completed successfully
  Normal  UpgradeSucceeded  25s    helm-controller  Helm upgrade succeeded for release default/podinfo-template.v3 with chart podinfo@6.6.2
  Normal  TestSucceeded     8s     helm-controller  Helm test succeeded for release default/podinfo-template.v3 with chart podinfo@6.6.2: 3 test hooks completed successfully