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

kustomize build shows error in v2.0.0 release #776

Closed
kfoozminus opened this issue Feb 7, 2019 · 14 comments
Closed

kustomize build shows error in v2.0.0 release #776

kfoozminus opened this issue Feb 7, 2019 · 14 comments

Comments

@kfoozminus
Copy link

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.

@kfoozminus
Copy link
Author

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.

@mgoodness
Copy link
Contributor

mgoodness commented Feb 7, 2019

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

@max-sixty
Copy link
Contributor

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?

@Shell32-Natsu
Copy link
Contributor

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

@max-sixty
Copy link
Contributor

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.

@Shell32-Natsu
Copy link
Contributor

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.

@max-sixty
Copy link
Contributor

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

@Shell32-Natsu
Copy link
Contributor

Will try to check it on my side

@Shell32-Natsu
Copy link
Contributor

Shell32-Natsu commented Oct 28, 2020

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

@max-sixty
Copy link
Contributor

Converting outside references to directories is very reasonable! Thanks

@mamiu
Copy link

mamiu commented Oct 30, 2020

@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?

@Shell32-Natsu
Copy link
Contributor

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?

@mamiu
Copy link

mamiu commented Oct 31, 2020

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).

@webern
Copy link

webern commented Nov 24, 2020

I'm using kubectl kustomize as I expect customers to be. I'm not sure how to find the version of kustomize but assume it's close (i.e. v2.X.X, not v3) as the previous comment.

Where do I find the documentation for v2? I have written kustomization.yaml files that seem to work with v3 when I try kustomize build but which cannot be applied with kubectl apply -k. I'm not 100% sure its version differences causing the issue, but I'd like to follow the documentation for the version customers would be expected to use (kubectl apply -k).

Thanks.

Edit: this issue for me might be that the ability to use inline strings in patches or patchesStrategicMerge was not available until some later version:

# path field is a relative file path of a JSON patch file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants