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 edit add base command adds dir as resource and not base #1556

Closed
reegnz opened this issue Sep 24, 2019 · 25 comments
Closed

kustomize edit add base command adds dir as resource and not base #1556

reegnz opened this issue Sep 24, 2019 · 25 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@reegnz
Copy link

reegnz commented Sep 24, 2019

Version

➜ kustomize version
Version: {KustomizeVersion:3.2.0 GitCommit:a3103f1e62ddb5b696daa3fd359bb6f2e8333b49 BuildDate:2019-09-20T10:10:22+02:00 GoOs:darwin GoArch:amd64}

Expected behavior

The command kustomize edit add base ../base should add a base to the kustomization file:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../base

#Actual behavior
Running the kustomize edit add base ../base command results in this:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base

How to reproduce

~
➜ mkdir test

~
➜ cd test

~/test
➜ mkdir base

~/test
➜ mkdir overlay

~/test
➜ cd base

~/test/base
➜ touch kustomization.yaml

~/test/base
➜ cd ..

~/test
➜ cd overlay

~/test/overlay
➜ touch kustomization.yaml

~/test/overlay
➜ kustomize edit add base ../base

~/test/overlay
➜ cat kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base
@reegnz
Copy link
Author

reegnz commented Sep 24, 2019

Would it be possible for kustomize to explicitly warn about these deprecation on stderr?

@bcmedeiros
Copy link

Hi, see https://github.com/kubernetes-sigs/kustomize/blob/master/docs/v2.1.0.md#resources-expanded-bases-deprecated

Thanks for pointing that out!

The issue is, I'm trying to apply my newly created kustomization.yaml file, after the relocation, and I get:

$ kubectl apply -k .
error: rawResources failed to read Resources: Load from path ../base failed: '../base' must be a file (got d='/Users/bruno.medeiros/git/apps-portal/base')

It seems that kubectl is failing when there is a resource that is a directory, not a file.

kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T23:42:50Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.7-eks-e9b1d0", GitCommit:"e9b1d0551216e1e8ace5ee4ca50161df34325ec2", GitTreeState:"clean", BuildDate:"2019-09-21T08:33:01Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

Do you know where can I report that?

@reegnz
Copy link
Author

reegnz commented Oct 17, 2019

Another thing that is quite confusing with the deprecation is that only using resources breaks kubectl apply -k, since kubectl doesn't really know about that new feature yet...

So now if you edit kustomizations with the kustomize cli and not by hand they won't be compatible with kubectl.

eg.:

➜ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.1", GitCommit:"d647ddbd755faf07169599a625faf302ffc34458", GitTreeState:"clean", BuildDate:"2019-10-02T17:01:15Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:27:17Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

➜ kubectl apply -k local
error: rawResources failed to read Resources: Load from path ../base failed: '../base' must be a file (got d='/Users/reegnz/example/base')

My kustomization in that case looks like this:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ../base

When can one expect a feature to also drip downstream into kubectl?
Also how can I find out what features are in downstream kubectl and what I cannot use with kubectl apply -k?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 15, 2020
@tomjohnburton
Copy link

tomjohnburton commented Jan 16, 2020

I am still getting this error.

$ kustomize edit add base ../../../bases/environment/staging-base

resources:
- Ingress.yml
- ../../../bases/microservice/services/account
- ../../../bases/environment/staging-base

@tomjohnburton
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 16, 2020
@marcusjwhelan
Copy link

@tomjohnburton @reegnz #1647 (comment) It worked for me as well using bases: instead of resources

working on windows docker for desktop

Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:07:57Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 28, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 28, 2020
@pommelinho
Copy link

Another thing that is quite confusing with the deprecation is that only using resources breaks kubectl apply -k, since kubectl doesn't really know about that new feature yet...

So now if you edit kustomizations with the kustomize cli and not by hand they won't be compatible with kubectl.

eg.:

➜ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.1", GitCommit:"d647ddbd755faf07169599a625faf302ffc34458", GitTreeState:"clean", BuildDate:"2019-10-02T17:01:15Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:27:17Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

➜ kubectl apply -k local
error: rawResources failed to read Resources: Load from path ../base failed: '../base' must be a file (got d='/Users/reegnz/example/base')

My kustomization in that case looks like this:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ../base

When can one expect a feature to also drip downstream into kubectl?
Also how can I find out what features are in downstream kubectl and what I cannot use with kubectl apply -k?

hey are there any news?

@reegnz
Copy link
Author

reegnz commented Aug 31, 2020

@pommelinho Didn't use kustomize for a while now, but checking the go.mod for kubectl:

https://github.com/kubernetes/kubectl/blob/18e781fa774127786b5a2092ed2dc0351dafdb87/go.mod#L46

Nope, it's still the same kustomize version that's used. :(

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pierluigilenoci
Copy link

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Sep 30, 2020
@pierluigilenoci
Copy link

/reopen

@k8s-ci-robot
Copy link
Contributor

@pierluigilenoci: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Shell32-Natsu
Copy link
Contributor

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Sep 30, 2020
@k8s-ci-robot
Copy link
Contributor

@Shell32-Natsu: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@marcellodesales
Copy link

marcellodesales commented Dec 17, 2020

@Shell32-Natsu, Any news on this???? Still with a problem with kubectl... kustomize 3.8.7 can use resources to load bases but apparently not kubectl... When should this be changed?

$ kubectl apply -k env/xxxx-westus-ppd-dev
error: rawResources failed to read Resources: Load from path ../../base failed: '../../base' must be
   a file (got d='/Users/marcello.desales/dev/gitlab.xxx.com/xxx/yyy/k8s/helm/charts/agent/output/agent/templates/base')

This is the version from docker-for-desktop...

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:12:48Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.11", GitCommit:"3a3612132641768edd7f7e73d07772225817f630", GitTreeState:"clean", BuildDate:"2020-09-02T06:46:33Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

@oofpez
Copy link

oofpez commented Jan 18, 2021

Also experiencing this. Using kustomize build works, but kubectl kustomize gives me this error.

@Shell32-Natsu
Copy link
Contributor

We are in the last (hopefully) step to remove apimachinery from kustomize. #2506 is used to track this work.

@AntonFriberg
Copy link

Seems like it is still an issue with kubectl 1.20.5

Using the multibase example from https://github.com/kubernetes-sigs/kustomize/tree/master/examples/multibases

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.5", GitCommit:"6b1d87acf3c8253c123756b9e61dac642678305f", GitTreeState:"clean", BuildDate:"2021-03-18T01:10:43Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:04:18Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
$ git clone --depth 1 [email protected]:kubernetes-sigs/kustomize.git
$ cd kustomize/example/multibases
$ kubectl kustomize .
Error: rawResources failed to read Resources: Load from path dev failed: 'dev' must be a file (got d='/home/antonfr/Git/github/kustomize/examples/multibases/dev')

It still works without issue using kustomize build.

$ kustomize build .
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: myapp
  name: cluster-a-dev-myapp-pod
spec:
  containers:
  - image: nginx:1.7.9
    name: nginx
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: myapp
  name: cluster-a-prod-myapp-pod
spec:
  containers:
  - image: nginx:1.7.9
    name: nginx
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: myapp
  name: cluster-a-staging-myapp-pod
spec:
  containers:
  - image: nginx:1.7.9
    name: nginx

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 17, 2021
@natasha41575
Copy link
Contributor

this is fixed in the most recent version of kubectl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests