Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to 2.2.0, started getting "kustomize build failed: kustomization.yaml is empty" #4509

Closed
1 task done
Tracked by #4556
joaocc opened this issue Dec 21, 2023 · 7 comments · Fixed by fluxcd/pkg#718
Closed
1 task done
Tracked by #4556
Labels
bug Something isn't working

Comments

@joaocc
Copy link

joaocc commented Dec 21, 2023

Describe the bug

Since upgrading to 2.2.0 (or 2.2.2) from 2.1.x, we started receiving the following errors kustomize build failed: kustomization.yaml is empty
This is from a Kustomization object (kustomize.toolkit.fluxcd.io/v1) pointing to a folder with no resources.
Previously these were silently ignored, and kustomizations would suceed.

Steps to reproduce

---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: level-1
  namespace: flux-system
spec:
  interval: 5m0s
  path: ./res/level-1
  dependsOn:
    - name: level-0
  prune: true
  sourceRef:
    kind: GitRepository
    name: my-own-git # this must match the name under which this repo has been created on the system

Expected behavior

The kustomization would process an empty folder and would suceed

Screenshots and recordings

No response

OS / Distro

Ubuntu

Flux version

v2.2.2

Flux check

flux check
► checking prerequisites
✔ Kubernetes 1.28.4-eks-8cb36c9 >=1.26.0-0
► checking version in cluster
✔ distribution: flux-2.2.2
✔ bootstrapped: false
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.37.2
✔ image-automation-controller: deployment ready
► ghcr.io/fluxcd/image-automation-controller:v0.37.0
✔ image-reflector-controller: deployment ready
► ghcr.io/fluxcd/image-reflector-controller:v0.31.1
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v1.2.1
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v1.2.3
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v1.2.3
► checking crds
✔ alerts.notification.toolkit.fluxcd.io/v1beta3
✔ buckets.source.toolkit.fluxcd.io/v1beta2
✔ gitrepositories.source.toolkit.fluxcd.io/v1
✔ helmcharts.source.toolkit.fluxcd.io/v1beta2
✔ helmreleases.helm.toolkit.fluxcd.io/v2beta2
✔ helmrepositories.source.toolkit.fluxcd.io/v1beta2
✔ imagepolicies.image.toolkit.fluxcd.io/v1beta2
✔ imagerepositories.image.toolkit.fluxcd.io/v1beta2
✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta1
✔ kustomizations.kustomize.toolkit.fluxcd.io/v1
✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2
✔ providers.notification.toolkit.fluxcd.io/v1beta3
✔ receivers.notification.toolkit.fluxcd.io/v1
✔ all checks passed

Git provider

N/A

Container Registry provider

N/A

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@stefanprodan stefanprodan added the bug Something isn't working label Dec 21, 2023
@stefanprodan
Copy link
Member

The workaround is to place in the dir a kustomization.yaml like so:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: []

This will be fixed next year.

@joaocc
Copy link
Author

joaocc commented Dec 21, 2023

Thanks for the prompt response. In this case, as a temporary workaround, i need to write an "empty" placeholder kustomization.yaml? That being the case, thanks for the workaround, and will look forward for the fix. Thanks

@joaocc joaocc closed this as completed Dec 21, 2023
@stefanprodan stefanprodan reopened this Dec 21, 2023
@joaocc
Copy link
Author

joaocc commented Dec 21, 2023

Hi.
I tried the workaround and I still got the same error. I was only able to solve the issue if, instead of resources: [] I create a dummy file and point the kustomization.yaml there.
Is this expected?
Thanks

@cep21
Copy link

cep21 commented Jan 5, 2024

@stefanprodan Does this qualify as a breaking change? Should it have had a version number increase? We were hit by a similar issue when upgrading flux.

@mrparkers
Copy link

Just chiming in that the resources: [] workaround worked for me.

@joawin
Copy link

joawin commented Jan 18, 2024

Hi,
i have the same problem.
When creating the file kustomization.yaml in the empty gitrepo i still get the message

"kustomize build failed: kustomization.yaml is empty"

kustomization.yaml in empty git repo

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: []

Kustomization File

apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: tenant-repo
  namespace: namespace
spec:
  interval: 1m
  path: "./"
  prune: true
  sourceRef:
    kind: GitRepository
    name: nameofrepo
  timeout: 2m
  serviceAccountName: m2m-sa
  decryption:
    provider: sops
    secretRef:
      name: tenant-agekey

@stefanprodan
Copy link
Member

This will be fixed in the next patch version, I have found a way to deal with the Kustomize break change.

Meanwhile @joawin you can set targetNamespace in your tenant Flux Kustomization as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants