allenporter/flux-local

Implicit Kustomization with subdirectories

ansarhun opened this issue · 7 comments

In the #80 PR the implicit handling was added but that did not handle if there are subdirectories that didn't contain a kustomisation file (this works in flux).

E.g.:
I have a kustomization set for the flux/apps folder which do not have a kustomization yaml file and it only contains subdirectories
flux/apps/database/postgresql

Checking the code: https://github.com/allenporter/flux-local/blob/6b8e0a8e8d2a017eedf5262fb972eb9b8711a9a2/flux_local/kustomize.py#L254C10-L254C10
now it only processes sub directories if it's explicitly kustomizable.
If that check is removed I was able to make it work locally

❯ flux-local get hr  -A --path ./clusters/home
NAMESPACE          NAME                         REVISION       CHART                                   SOURCE
database           postgresql                   12.7.1         database-postgresql                     bitnami-charts

without the change

❯ flux-local get hr  -A --path ./clusters/home
no HelmRelease objects found in cluster

Is it possibly to remove this limitation and allow to process sub directories as well?

@ansarhun can you point me your repo where I can try this out? Thanks.

I've been considering moving to flux build to take over this behavior so this is a good reason to move if its not compatible.

@allenporter my repo is private but I put together a sample repo with the same structure: https://github.com/ansarhun/flux-local-test

I've confirmed that flux build can build this properly and find the HelmRelease

$ flux build ks apps --path ./flux/apps/ --kustomization
-file ./clusters/home/apps.yaml --dry-run 
apiVersion: v1
kind: Namespace
metadata:
  labels:
    kustomize.toolkit.fluxcd.io/name: apps
    kustomize.toolkit.fluxcd.io/namespace: flux-system
    kustomize.toolkit.fluxcd.io/prune: disabled
  name: database
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  labels:
    kustomize.toolkit.fluxcd.io/name: apps
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: postgresql
  namespace: database
spec:
  chart:
    spec:
      chart: postgresql
      sourceRef:
        kind: HelmRepository
        name: bitnami-charts
        namespace: flux-system
      version: 12.7.1
  interval: 15m

Fixed in #298

Thank you @ansarhun 💯

Thank you @allenporter with the quick merge and release, and for making this project!