Flux drift detection for Helm Releases

How to enable Helm drift detection in Flux

At present, Helm releases are not by default checked for drift compared to cluster-state. To enable experimental drift detection, you must add the --feature-gates=DetectDrift=true flag to the helm-controller Deployment.

Enabling it will cause the controller to check for drift on all Helm releases using a dry-run Server Side Apply, triggering an upgrade if a change is detected. For detailed information about this feature, refer to the documentation.

To enable drift detection during bootstrap add the following patches to the flux-system kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
  - gotk-components.yaml
  - gotk-sync.yaml
  - patch: |
      # Enable drift detection and correction
      - op: add
        path: /spec/template/spec/containers/0/args/-
        value: --feature-gates=DetectDrift=true,CorrectDrift=true
      # Enable debug logging for diff output (optional)
      - op: replace
        path: /spec/template/spec/containers/0/args/2
        value: --log-level=debug      
      kind: Deployment
      name: helm-controller