kubernetes-sigs / kubebuilder

Kubebuilder - SDK for building Kubernetes APIs using CRDs
http://book.kubebuilder.io
Apache License 2.0
7.77k stars 1.43k forks source link

kubebuilder fialed when I initialize a new project (go.mod file indicates go 1.16, but maximum supported version is 1.15) #2207

Closed wuzm2k05 closed 3 years ago

wuzm2k05 commented 3 years ago

What broke? What's expected?

OS: Fedora release 31 (Thirty One)

I am new to kubebuilder, thank for you answer in advance.( I searched the issues but didn't find the similar issue) I was using kubebuilder to init a new project but I got the following error. Then I realized kubebuilder doesn't support go 1.16, so I uninstalled go 1.16 and installed go 1.15.13. Then I run the command again, but got the same error!! I noticed the go.mod file created by kubebuilder, it require go 1.16!! Anything wrong I did?

I expect I can run the command success-full.

=============================================

go version

go version go1.15.13 linux/amd64 =============================================

kubebuilder init --domain my.domain --repo my.domain/guestbook

Writing kustomize manifests for you to edit... Writing scaffold for you to edit... Get controller runtime: $ go get sigs.k8s.io/controller-runtime@v0.8.3 Update dependencies: $ go mod tidy go mod tidy: go.mod file indicates go 1.16, but maximum supported version is 1.15 Error: failed to initialize project: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 1 Usage: kubebuilder init [flags]

Examples:

Initialize a new project with your domain and name in copyright

kubebuilder init --plugins go/v3 --domain example.org --owner "Your name"

Initialize a new project defining an specific project version

kubebuilder init --plugins go/v3 --project-version 3

Flags: --component-config create a versioned ComponentConfig file, may be 'true' or 'false' --domain string domain for groups (default "my.domain") --fetch-deps ensure dependencies are downloaded (default true) -h, --help help for init --license string license to use to boilerplate, may be one of 'apache2', 'none' (default "apache2") --owner string owner to add to the copyright --project-name string name of this project --project-version string project version (default "3") --repo string name to use for go module (e.g., github.com/user/repo), defaults to the go package of the current working directory. --skip-go-version-check if specified, skip checking the Go version

Global Flags: --plugins strings plugin keys to be used for this subcommand execution

2021/06/09 17:49:43 failed to initialize project: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 1

==========================================

Reproducing this issue

see above.

KubeBuilder (CLI) Version

Version: main.version{KubeBuilderVersion:"3.1.0", KubernetesVendor:"1.19.2", GitCommit:"92e0349ca7334a0a8e5e499da4fb077eb524e94a", BuildDate:"2021-05-27T17:54:28Z", GoOs:"linux", GoArch:"amd64"}

PROJECT version

none

Plugin versions

NA

Other versions

go version: 1.15.13

Extra Labels

No response

camilamacedo86 commented 3 years ago

The problem seems that you are using go 1.15. Did you try to do the same with go 1.16 installed?

wuzm2k05 commented 3 years ago

yes. At first I was using go 1.16 but got the error. Then I uninstalled go 1.16, and installed go 1.15 but go the same error. (I checked the go mod file, go 1.16 still required in that file)

tpiperatgod commented 3 years ago

I can initialize the project normally with go 1.16(with gcc installed) while get the same error(Error: failed to initialize project: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 1) in go1.15 environment.

So is there a problem with the documentation instructions? https://book.kubebuilder.io/quick-start.html#prerequisites

wuzm2k05 commented 3 years ago

if I edit the go.mod and change "go 1.16" to "go 1.15". Then it seems everything is okay, I can then create api successfully. So how kubebuilder generate the go.mod file? where it find the go version and generate go.mod file?

maximveksler commented 3 years ago

Getting the same error. Using go go version go1.15.13 linux/amd64

max@max-ThinkPad-E14:~/projects/guestbook$ kubebuilder init --domain my.domain --repo my.domain/guestbook
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.8.3
go: downloading sigs.k8s.io/controller-runtime v0.8.3
go: downloading k8s.io/apimachinery v0.20.2
go: downloading k8s.io/client-go v0.20.2
go: downloading k8s.io/utils v0.0.0-20210111153108-fddb29f9d009
go: downloading golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
go: downloading k8s.io/apiextensions-apiserver v0.20.1
go: downloading github.com/evanphx/json-patch v4.9.0+incompatible
go: downloading gomodules.xyz/jsonpatch/v2 v2.1.0
go: downloading k8s.io/klog/v2 v2.4.0
go: downloading github.com/prometheus/client_golang v1.7.1
go: downloading github.com/google/gofuzz v1.1.0
go: downloading k8s.io/api v0.20.2
go: downloading golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
go: downloading github.com/gogo/protobuf v1.3.1
go: downloading golang.org/x/sys v0.0.0-20201112073958-5cba982894dd
go: downloading github.com/imdario/mergo v0.3.10
go: downloading github.com/golang/protobuf v1.4.3
go: downloading golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
go: downloading github.com/go-logr/logr v0.3.0
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.10.0
go: downloading github.com/modern-go/reflect2 v1.0.1
go: downloading golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
go: downloading github.com/prometheus/procfs v0.2.0
go: downloading sigs.k8s.io/yaml v1.2.0
go: downloading k8s.io/component-base v0.20.2
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/googleapis/gnostic v0.5.1
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading gopkg.in/inf.v0 v0.9.1
go: downloading k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.0.2
go: downloading github.com/json-iterator/go v1.1.10
go: downloading google.golang.org/protobuf v1.25.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading gopkg.in/yaml.v2 v2.3.0
go: downloading gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
go: downloading github.com/google/go-cmp v0.5.2
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/google/uuid v1.1.2
go: downloading golang.org/x/text v0.3.4
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading google.golang.org/appengine v1.6.6
Update dependencies:
$ go mod tidy
go mod tidy: go.mod file indicates go 1.16, but maximum supported version is 1.15
Error: failed to initialize project: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 1
Usage:
  kubebuilder init [flags]

Examples:
  # Initialize a new project with your domain and name in copyright
  kubebuilder init --plugins go/v3 --domain example.org --owner "Your name"

  # Initialize a new project defining an specific project version
  kubebuilder init --plugins go/v3 --project-version 3

Flags:
      --component-config         create a versioned ComponentConfig file, may be 'true' or 'false'
      --domain string            domain for groups (default "my.domain")
      --fetch-deps               ensure dependencies are downloaded (default true)
  -h, --help                     help for init
      --license string           license to use to boilerplate, may be one of 'apache2', 'none' (default "apache2")
      --owner string             owner to add to the copyright
      --project-name string      name of this project
      --project-version string   project version (default "3")
      --repo string              name to use for go module (e.g., github.com/user/repo), defaults to the go package of the current working directory.
      --skip-go-version-check    if specified, skip checking the Go version

Global Flags:
      --plugins strings   plugin keys to be used for this subcommand execution

2021/06/24 21:16:32 failed to initialize project: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 1
maximveksler commented 3 years ago

However switching to go go version go1.16.5 linux/amd64 does seem to help.

max@max-ThinkPad-E14:~/projects/guestbook$ kubebuilder init --domain my.domain --repo my.domain/guestbook
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.8.3
go: downloading github.com/evanphx/json-patch v0.5.2
go: downloading k8s.io/client-go v1.5.2
Update dependencies:
$ go mod tidy
go: downloading github.com/onsi/ginkgo v1.14.1
go: downloading github.com/onsi/gomega v1.10.2
go: downloading github.com/go-logr/zapr v0.2.0
go: downloading go.uber.org/zap v1.15.0
go: downloading github.com/stretchr/testify v1.6.1
go: downloading github.com/Azure/go-autorest v14.2.0+incompatible
go: downloading go.uber.org/goleak v1.1.10
go: downloading go.uber.org/atomic v1.6.0
go: downloading go.uber.org/multierr v1.5.0
go: downloading github.com/Azure/go-autorest/autorest v0.11.1
go: downloading golang.org/x/lint v0.0.0-20200302205851-738671d3881b
go: downloading honnef.co/go/tools v0.0.1-2020.1.3
go: downloading cloud.google.com/go v0.54.0
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee
go: downloading gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
go: downloading github.com/Azure/go-autorest/autorest/adal v0.9.5
go: downloading github.com/nxadm/tail v1.4.4
go: downloading github.com/Azure/go-autorest/tracing v0.6.0
go: downloading github.com/Azure/go-autorest/autorest/mocks v0.4.1
go: downloading github.com/Azure/go-autorest/logger v0.2.0
go: downloading golang.org/x/tools v0.0.0-20200616133436-c1934b75d054
go: downloading github.com/Azure/go-autorest/autorest/date v0.3.0
go: downloading github.com/form3tech-oss/jwt-go v3.2.2+incompatible
go: downloading github.com/kr/pretty v0.2.0
go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: downloading github.com/kr/text v0.1.0
go: downloading golang.org/x/mod v0.3.0
Next: define a resource with:
$ kubebuilder create api
camilamacedo86 commented 3 years ago

The version go version go1.15.13 is not supported. If you are using the latest release then, you need to use go 1.16.

Into the code, has a place where they go version is checked. @rashmigottipati would like to check it and see if you find this validation for we change that and return an error to let the users know that 1.15 is no longer supported? WDYT? Would you like to help us out in this one?

c/c @estroz

rashmigottipati commented 3 years ago

@camilamacedo86 Sure, I'll work on this.

/assign @rashmigottipati

wuzm2k05 commented 3 years ago

when you say latest release, that means kubebuilder 3.1.0 version, right? Andy you may want to update "Quick Start" books, it still say one of prerequisite is "go version v1.15+ and < 1.16". Thanks!

swiftslee commented 3 years ago

@camilamacedo86 @rashmigottipati Hi, I found that #2182 upgraded the go version to v1.16. I've opened a pr for the quickstart document. Please take a look at #2257 if you are free. Thanks.

zhamdoctor commented 3 years ago

its not working,though 1.16 doesnt help at all.i want to read running log with --verbose,but it seems nothing

zhamdoctor commented 3 years ago

its not working,though 1.16 doesnt help at all.i want to read running log with --verbose,but it seems nothing

oh,i resolve it! after upgrading go version to 1.16,it doesnt help.but logs shows dial up refused .so i changed my GOPROXY with cn for China. it worked!

fishANDdog commented 2 years ago

I have same problem, and i have resolved it. The solution is to install GCC. commond line is : yum install gcc