kustomize: [Linux only] kustomization.yaml not found if it's a symlink

Describe the bug

kustomize build returns the following error when run in a directory where a kustomization.yaml file exists, but is a symlink rather than a regular file.

Error: unable to find one of 'kustomization.yaml', 'kustomization.yml' or 'Kustomization' ' in directory

It works as expected when kustomization.yaml with the same contents is a regular file.

Kustomize version

v4.4.1

Platform

Linux

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Just to confirm it does prevent you from using kustomize in Bazel without workarounds. --load-restrictor LoadRestrictionsNone resolves this issue in bazel.

Not supporting symlinks has been a hindrance for quite a long time… and it’s still the case on the very latest version of kustomize v.4.5.5.

Symlinks are a core part of unix administration, use cases include:

  • testing different adjacent versions of kustomization.yaml by replacing symlinks
  • a repo full of different kustomizations that I would like to just symlink to a working directory and execute, eg:

https://github.com/HariSekhon/Kubernetes-configs

Workarounds such as cp instead of ln are not ideal, because you are duplicating contents and then have to keep both copies up to date - this is exactly the sort of thing symlinks were designed to solve.

I’m not familiar with the Kustomize code base but am hoping it’s a fairly easy file existence call check to fix this?

--load-restrictor LoadRestrictionsNone resolves this issue in bazel.

I don’t think this is true. There’s some other issues with symlink resolution. If you have a mix of generated and source files, things get screwy since some of those get symlinked. Kustomize appears to expect all paths to be relative to the resolved location rather than the symlinked one.

The only workaround I’ve found is to copy all the files to a single tree (in Bazel, this means tarring them up and extracting them later).