kustomize: "Load from path ../ failed: security, file '...' is not in or below '...'
I just upgraded to the latest HEAD to get support for files in secretGenerator and it looks like there’s some “security” mechanism that’s been added that breaks our workload:
FATA[0011] exiting dev mode because first run failed: deploy failed: reading manifests: kustomize build: Running [kustomize build services/kubernetes/dev]: stdout , stderr: Error: rawResources failed to read Resources: Load from path ../admin.yaml failed: security; file '../admin.yaml' is not in or below '/home/.../services/kubernetes/dev'
How do I bypass this?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 23 (4 by maintainers)
Commits related to this issue
- build: Fix compatibility with new kustomize. The newest versions of kustomize block the use of relative paths in configuration. This path fixes our config to work without error. See https://github.... — committed to vrutkovs/cluster-api by vrutkovs 5 years ago
- Changes in Kubernetes v2.x breaks this example Only `bases` can be accessed in higher directories. https://github.com/kubernetes-sigs/kustomize/pull/700 https://github.com/kubernetes-sigs/kustomize/i... — committed to ViggoV/kustomize by ViggoV 4 years ago
@hach-que The files in
secretGeneratorsneed to be relative paths in the kustomization directory or subdirectory.../admin.yamlgoes outside the kustomization directory. This is blocked in Kustomize 2.0.0.@Liujingfang1 2.0.0 blocks relative paths everywhere as far as I can tell.
The issue is that
kustomization.yamlis hard-coded, so how can I have two different kustomization targets when they need to draw on the contents of the Git repository? I can’t use relative parent paths anymore.Imagine I have a directory structure like this (right now):
With relative paths blocked, your proposal is now to put the kustomization.yaml file in the parent directory, like this:
Except that doesn’t work because you can’t have two files both named
kustomization.yamlin the top level directory. There doesn’t appear to be any way to override the path or name of thekustomization.yamlfile either when invokingkustomize.Could you elaborate what was the motivation for blocking paths that are above given
kustomization.yaml?This is really annoying.
I had to go from
to
What I really want:
cannot share patches anymore 😢
edit: it works with
--load_restrictorflag, but somehow the flag doesn’t work when usingkubectl kustomizeI cannot understand this Kustomize team. (I’m sorry). So, everyone is complaining and explain that the relative-path block is very counterintuitive and the team just comes passing by casually, saying “NO” with little useful explanation? Huh…?
I believe it is not possible to reuse common patches in this way?
@flickerfly the following works for v4.0.5
kustomize build --load-restrictor LoadRestrictionsNoneMy use case is I have a few secrets in a shared encrypted keybase git repo used by applications not only run in kubernetes (mobile, desktop and various IOT apps) and I’d rather not have multiple copies or a makefile to shuffle files around before kustomize is run.
Ok, but secretGenerator it is not resource, it is part of
kustomization.yaml. It seems thatkubectl create secret generic tls --from-file=./certs/tls.cert --from-file=./certs/tls.keyis the only solution now 😦 (security doesn’t matter — it is used for local, since no doubt for production secrets created in another way).Kustomize tries to protect developers from mistakes, it is great, but as workaround for such bugs shell script is used, that’s even worse 😦
As workaround, just add hard links (as symbolic links are also forbidden) 😦
This is literally false. They cannot be located anywhere, which is the fundamental reason why users are complaining.
Two poorly designed features (probably not so poor when individually used) have broken the idea of using Kustomize to
customiseconfiguration: 1) an inaccurate recursion detection - only checks for whether a folder is accessible by a yaml and not if it is actually linked, and 2) requiring all files to be under or on the same level of a yamlThis functionality is most likely breaking security by having users change their directory structures to have entire projects under one folder which is inside a repository.
@hach-que You can put the files used by both to base and include that base in both dev and prod.
@mohnishkodnani I’m not sure I understand your problem. The base
defaulthas resourcesrbacandmanagers, but the overlay doesn’t work. Is that the problem you mean?@Liujingfang1 I ran into the same issue after upgrading to
kustomize 2.x. I was able to fix the problem by following your tip! To summarize the change I needed to make:I have the following folder structure:
To fix the problem:
base/kustomization.yamlwith:overlays/staging/kustomization.yamlandoverlays/production/kustomization.yamlto replace:… with …
@swapnild2111 that is for version 3. In version 4 it is
--load-restrictor. See https://github.com/kubernetes-sigs/kustomize/issues/3746@flickerfly https://github.com/kubernetes-sigs/kustomize/issues/3746 I guess it is hyphenated now
--load-restrictor, the documentation needs to be updated