kustomize-controller icon indicating copy to clipboard operation
kustomize-controller copied to clipboard

Documentation unclear: Flux Kustomization patches do not apply over nested kustomizations

Open ondrejkolin opened this issue 8 months ago • 2 comments

We use following kustomizations structure in our projects:

kustomize.config.k8s.io/v1beta1 -> kustomize.toolkit.fluxcd.io/v1 -> kustomize.toolkit.fluxcd.io/v1 -> helmrelease

In my setup I have a patch on all top-level flux kustomizations with a patch for all helm releases - full kustomization file.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-components.yaml
- gotk-sync.yaml
- kustomization-in-the-middle.yaml
patches:
  - target: 
      kind: Kustomization
      group: kustomize.toolkit.fluxcd.io
      version: v1
    patch: |
      - op: add
        path: /spec/patches
        value:
          - target:
              kind: HelmRelease
            patch: |-

The patch is not delivered to the HR. This makes sense as when I do flux trace on that HR, it's only dependend on it's parent kustomization.

Altough documentation mention writing patches at top-level Flux kustomization as a feature used in bulk shard assignment:

For example, assuming you want to assign a tenant to a particular shard, in the root Flux Kustomization that reconcile the tenant’s Flux sources, kustomizations and Helm releases label these resources as follows:

Image is a screenshot of the code from the documentation image

I think that the documentation is wrong. I have a very minimal example where it's not working: https://gitlab.com/ondrej.kolin/flux-helmrelease-patch-test

ondrejkolin avatar Oct 25 '23 14:10 ondrejkolin