kustomize build shows error in v2.0.0 release

Created on 7 Feb 2019  Â·  13Comments  Â·  Source: kubernetes-sigs/kustomize

kustomize build <dir> shows the following error -

Error: rawResources failed to read Resources: Load from path ../rbac/rbac_role.yaml failed: security; file '../rbac/rbac_role.yaml' is not in or below '/home/<...>/go/src/github.com/<...>/kubebuilder-sample/config/default'

Rolled back to previous release and it works.

Most helpful comment

Probably due to #700. Dupe of #766.

In kustomize v2 kustomization.yaml can only refer to files in the same directory as itself, or in subdirectories. Only bases can refer to outside paths.

bases:
- ../base <- ok

resources:
- deployment.yaml <- ok
- foo/service.yaml <- ok
- ../pdb.yaml <- not ok
- ../baz/rbac.yaml <- not ok

All 13 comments

kustomization.yaml contains -

resources:                                                                                                                                                                                                     
 - ../rbac/rbac_role.yaml                                                                                                                                                                                       
 - ../rbac/rbac_role_binding.yaml                                                                                                                                                                               
 - ../manager/manager.yaml                                                                                                                                                                                      
 - ../rbac/auth_proxy_service.yaml                                                                                                                                                                              
 - ../rbac/auth_proxy_role.yaml                                                                                                                                                                                 
 - ../rbac/auth_proxy_role_binding.yaml 

tried moving manager and rbac folder to the directory where kustomization.yaml is. and changing to -

resources:                                                                                                                                                                                                     
 - /rbac/rbac_role.yaml                                                                                                                                                                                       
 - /rbac/rbac_role_binding.yaml                                                                                                                                                                               
 - /manager/manager.yaml                                                                                                                                                                                      
 - /rbac/auth_proxy_service.yaml                                                                                                                                                                              
 - /rbac/auth_proxy_role.yaml                                                                                                                                                                                 
 - /rbac/auth_proxy_role_binding.yaml 

also tried changing them to absolute path like /home/.../rbac/..

still gives same error.

Probably due to #700. Dupe of #766.

In kustomize v2 kustomization.yaml can only refer to files in the same directory as itself, or in subdirectories. Only bases can refer to outside paths.

bases:
- ../base <- ok

resources:
- deployment.yaml <- ok
- foo/service.yaml <- ok
- ../pdb.yaml <- not ok
- ../baz/rbac.yaml <- not ok

For people coming back to this error — bases works but is deprecated.

For maintainers — what's the recommended way for people to handle this case?

bases is replaced by resources. Just use resources like bases.

What about this case?

In kustomize v2 kustomization.yaml can only refer to files in the same directory as itself, or in subdirectories. Only bases can refer to outside paths.

In kustomize V2, bases is used. In V3, resources is used to refer bases. Although you can still use bases in V3 but as you said it's deprecated.

I think we're talking past each other. Does resources allow referring to outside paths? If not, what should people use?

Will try to check it on my side

OK I made a mistake. You can refer an outside base directory but not a single YAML file. So what you can do is put your outside files into a base kustomize directory or you can try to use components

Converting outside references to directories is very reasonable! Thanks

@Shell32-Natsu

I still don't get it. bases are deprecated. As you can see here.

The bases field was deprecated in v2.1.0

And resources don't support referring to a parent directory or file. If I refer to a directory like so ...

resources:
  - ../../resources

... and run kubectl kustomize manifests/envs/dev I get the error:

Error: rawResources failed to read Resources: Load from path ../../resources failed:
'../../resources' must be a file (got d='/<PATH TO MY PROJECT>/manifests/resources')

And if I refer to the kustomization.yaml in the ../../resources directory...

resources:
  - ../../resources/kustomization.yaml

... and run kubectl kustomize manifests/envs/dev I get this error message:

Error: rawResources failed to read Resources: Load from path ../../resources/kustomization.yaml failed:
security; file '../../resources/kustomization.yaml' is not in or below '/<PATH TO MY PROJECT>/manifests/envs/dev'

So the question to the maintainers from @max-sixty:

What's the recommended way for people to handle this case?

Is it related to this issue?

The resources is what kustomize using now to refer base resources so what you see is different from mine. What's version of kustomize are you using?

As I said I'm using kubectl kustomize which still seems to be kustomize v2.0.3.

Since I'm using kustomize in a CI/CD pipeline I've now created a custom image that uses the latest version of kustomize. That solved the issue for me.

For others who're looking into that in the future: It still may take some time until the latest version of kustomize is included in kubectl (according to this FAQ page).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidknezic picture davidknezic  Â·  3Comments

lionelvillard picture lionelvillard  Â·  4Comments

monopole picture monopole  Â·  3Comments

drekle picture drekle  Â·  4Comments

nicks picture nicks  Â·  3Comments