Kubebuilder: quickstart fails during go vet step

Created on 17 Apr 2019  路  19Comments  路  Source: kubernetes-sigs/kubebuilder

So i'm on a mac trying to go through the quickstart.
I installed kubebuilder following the instructions but I get the following error during kubebuilder init:

$ kubebuilder init --domain k8s.io --license apache2 --owner "The Kubernetes Authors"
Run `dep ensure` to fetch dependencies (Recommended) [y/n]?
y
dep ensure
Solving failure: package k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1 does not exist within project k8s.io/client-go
2019/04/17 17:48:45 exit status 1

Then I cloned the client-go repo to $GOPAHT/src/k8s.io/ and tried again, only this time I got:

$ kubebuilder init --domain k8s.io --license apache2 --owner "The Kubernetes Authors"
Run `dep ensure` to fetch dependencies (Recommended) [y/n]?
y
dep ensure
Running make...
make
go generate ./pkg/... ./cmd/...
go fmt ./pkg/... ./cmd/...
go vet ./pkg/... ./cmd/...
# k8s.io/client-go/rest
../../../../../pkg/mod/k8s.io/[email protected]+incompatible/rest/request.go:598:31: not enough arguments in call to watch.NewStreamWatcher
    have (*versioned.Decoder)
    want (watch.Decoder, watch.Reporter)
make: *** [vet] Error 2
2019/04/17 17:52:50 exit status 2

/kind bug

kinbug lifecyclrotten

Most helpful comment

I had this issue and was able to fix with with go-modules by having my go.mod file contain:

go 1.12

replace (
    k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471
    k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190221221350-bfb440be4b87
    k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
    k8s.io/client-go => k8s.io/client-go v10.0.0+incompatible
)

All 19 comments

note that dep ensure does not appear to work even in this repo currently :disappointed:

so after spending an entire day figuring out the dependency graph between code-generator, client-go, apimachinery, etc. etc. I think the solution for this is to disable go modules. Otherwise, it seems like the dep ensure step is trying to pick up the dependencies from client-so's latest release (v11.0). Which I guess makes sense /shrug

@BenTheElder do you have go modules enabled as well?

export GO111MODULE="off"made no difference. I didn't (don't?) think dep was aware of this.

It appears the dep doesn't always work well.
We are actively working on enable go modules for all 3 kubebuilder repos.

I had this issue and was able to fix with with go-modules by having my go.mod file contain:

go 1.12

replace (
    k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471
    k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190221221350-bfb440be4b87
    k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
    k8s.io/client-go => k8s.io/client-go v10.0.0+incompatible
)

Came here from getting a similar issue when trying to build the kubernetes client-go examples (https://github.com/kubernetes/client-go/blob/master/examples/in-cluster-client-configuration/main.go).

The version from @runyontr work for me!

Can people confirm that v2 with native go module support works fine?

@runyontr solves client go issue but I'm getting this error now:
vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go:170:8: undefined: webhook.ManifestOptions.

@gmlp which version of kubebuilder are you using? Which scaffolding version?

Hi @DirectXMan12 , I'm using this setup:
go version go1.12.5 darwin/amd64
KubeBuilderVersion:"2.0.0-alpha.2
KustomizeVersion:v2.0.4-kubebuilder-special-edition
dep version : v0.5.3
Scaffolding version: 1

@gmlp scaffolding version 1 doesn't support go modules, so if you're trying to use @runyontr's solution with scaffolding v1, that could cause issues.

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

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

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

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

I'm hitting this error when trying to use kubebuilder 2.1.0 on a fresh project. Is it supposed to work on a fresh project (empty go.mod)?

I tried doing

require (
k8s.io/api kubernetes-1.16.3
k8s.io/apimachinery kubernetes-1.16.3
k8s.io/client-go kubernetes-1.16.3
)

which seems to allow it to compile but not sure this is the correct approach.

Make sure you have the latest version of KB, and then it should work on an empty go.mod file.

I had to blow away go/pkg/mod, then it worked. I don't understand go modules well enough to know why this worked though.

huh. That's like the universal package manager trick: "when in doubt, clear the package cache".

Was this page helpful?
0 / 5 - 0 ratings