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

Support go 1.18 #2559

Closed
6 tasks done
camilamacedo86 opened this issue Mar 22, 2022 · 33 comments · Fixed by #2714
Closed
6 tasks done

Support go 1.18 #2559

camilamacedo86 opened this issue Mar 22, 2022 · 33 comments · Fixed by #2714
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@camilamacedo86
Copy link
Member

camilamacedo86 commented Mar 22, 2022

What do you want to happen?

Make Kubebuilder supports Golang 1.18

Following the main places that need to be changed to achieve this goal:

  • Bump go.mod scaffold for go/v3 scaffolds
  • Also, ensure that we bump the go version in the GitHub Actions and CI.
  • Verify any other places that we should do this update and ensure that all will be properly done.
  • Ensure that you make generate before pushing the PR with the changes.

Following what was identified that would also be required to be done to achieve this goal

We should NOT

Extra Labels

No response

@camilamacedo86 camilamacedo86 added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 22, 2022
@AvineshTripathi
Copy link

@camilamacedo86 i would like to do this, pretty new to kubebuilder so i was wondering if this could be a issue to start with

@AvineshTripathi
Copy link

/assign

@camilamacedo86
Copy link
Member Author

I think that is good @AvineshTripathi.
Feel free to ping me if you need.

@AvineshTripathi
Copy link

AvineshTripathi commented Mar 24, 2022

Looking at previous bump of go version in kubebuilder 15e3ef3 for 1.15->1.16 all the dockerfiles present in the docs/books/src were too updated to new version, also some other changes done in the plugins as seen in the above link so are we suppose to do the same this time @camilamacedo86

@AlmogBaku
Copy link
Member

/assign

@camilamacedo86 camilamacedo86 added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Mar 24, 2022
@abeer91
Copy link

abeer91 commented Mar 28, 2022

Not sure if this needs a whole other issue, I can create one if needed. Currently, the version of kube builder available through home brew depends on golang 1.18 , and it doesn't work with the same create-api errors reported.

https://formulae.brew.sh/formula/kubebuilder

@AlmogBaku
Copy link
Member

We probably need to have a new release to solve it. Merging it will allow you to temporary solve it by using the head version

@camilamacedo86
Copy link
Member Author

Hi @abeer91,

the brew formula is not kept maintained by us.
If it is using go 1.18 that is wrong since KB still not supporting this version.

@abeer91
Copy link

abeer91 commented Mar 28, 2022

Thanks @camilamacedo86 , do you know who maintains this?

@AlmogBaku
Copy link
Member

@abeer91, you should probably open an issue in the brew-core repo

@viveksahu26
Copy link

Hey @camilamacedo86 , I found similar to above issue in one of KataCoda scenario, Kubernetes Extensibility: Develop an Operator with Kubebuilder.

controlplane $ go version
go version go1.18.1 linux/amd64
controlplane $ kubebuilder init --domain d2iq.com
Error: failed to initialize project: unable to run pre-scaffold tasks of "base.go.kubebuilder.io/v3": target directory is not empty (only go.mod, go.sum, files and directories with the prefix ".", files with the suffix ".md" or capitalized files name are allowed); found existing file "go1.18.1.linux-amd64.tar.gz"
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 a 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

2022/04/16 22:43:28 failed to initialize project: unable to run pre-scaffold tasks of "base.go.kubebuilder.io/v3": target directory is not empty (only go.mod, go.sum, files and directories with the prefix ".", files with the suffix ".md" or capitalized files name are allowed); found existing file "go1.18.1.linux-amd64.tar.gz"

@camilamacedo86
Copy link
Member Author

Hi @viveksahu26,

The 1.18 is not supported so far. So, trying to use the latest Kubebuilder release with go 1.18 will fail.

@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Apr 22, 2022

This issue was discussed in the C+R, Kubebuilder meeting yesterday. @AlmogBaku, thank you for helping us identify the impact and how we can address this requirement.

@varshaprasad96 raised a good point and check that we had been only updating the go version to officially support when we update the deps to avoid issues faced in the past. She could identify some scenarios such as:

For example, with some recent changes, we can't use k8s 1.23 with older versions of Go (For ex: operator-framework/operator-sdk#5558 (comment)) - this is a vice versa case.

Therefore, to bump the go version 1.18 for the go/v3 plugin:

  • a) Update controller runtime (Its maintainers are ok with us doing that now in the master since it is using k8s 1.24 alpha deps already)
  • b) Waiting for a controller-runtime new release using go 1.18
  • c) Bump go 1.18 and controller-runtime on Kubebuilder go/v3 plugin and CLI

Then, to update the Kubebuilder CLI/API:

The config-gen ( which is an alpha, experimental and optional option ) uses controller tools as dep importing the code. So we also need to:

  • a) Update controller tools with go 1.18 and its deps to use k8s 1.24
  • b)Then, ask for a controller-tools release
  • c) So that, we can bump Kubebuilder CLI/API and deps to use go 1.18, controller-tools, and k8s api 1.24
  • d) When the above PR be done we will need to also get merged the PR to update the infra tests: Bump kubebuilder-presubmits to use go 1.18 kubernetes/test-infra#25775

Additionally

  • we should not update go/v2 since we cannot upgrade the deps used on it and they will not be compatible with go 1.18.
  • we also discussed the CLI and go/v3 bumps should probably be done in different PRs so then, we can discuss, check and analyse the impact and merit of the changes for each case.

I am adding this info to the description so that we can clarify what needs to be done here so we are able to accomplish this goal.

c/c @ryanbrainard @rashmigottipati

@AlmogBaku
Copy link
Member

I think go/v2 should also use go 1.18; there is no reason not to do so :)

@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Apr 22, 2022

Hi @AlmogBaku,

We can only update go/v2 to use go version 1.18 if we are able to upgrade the controller runtime and k8s deps used on it. Then, if we want to do that we need to check if has any reason for we have been not updating the go/v2 first.

@camilamacedo86
Copy link
Member Author

Hi @AlmogBaku,

We will also need to update and change the release tools to work with go 1.18

@Vaxuite
Copy link

Vaxuite commented May 9, 2022

Hi @camilamacedo86 is it ok if I pick these tasks up? We are blocked on this for upgrading to go 1.18 at Thought Machine so would like to try help accelerate this as much as possible.

Hi @AlmogBaku,

We will also need to update and change the release tools to work with go 1.18

@camilamacedo86
Copy link
Member Author

HI @Vaxuite,

The first step is we have a controller runtime and controller-tools release, which supports go 1.18. Have we that already? Would you like to help with this? I do not think that @AlmogBaku is working on this part.

@camilamacedo86
Copy link
Member Author

Also, just to supplement. I checked that go/v2 can only scaffold v1beta1 CRD versions ( since it is the legacy layout ). Therefore, we would only be able to upgrade it to use:

  • ControllerToolsVersion = "v0.6.2"
  • ControllerRuntimeVersion = "v0.9.2"
  • K8s Version 1.21
  • Go version: 1.16

In this way, we cannot upgrade this one.

c/c @AlmogBaku @ryanbrainard @varshaprasad96

@Vaxuite
Copy link

Vaxuite commented May 9, 2022

@camilamacedo86 I've done the controller runtime pr https://github.com/kubernetes-sigs/controller-runtime/pull/1895/files. Ill have a look at controller-tools in the coming days.

@Vaxuite
Copy link

Vaxuite commented May 10, 2022

Are you sure we need to update controller-runtime @camilamacedo86 it already works with go 1.18?

@AlmogBaku
Copy link
Member

Hi, As far as I know, we're waiting for controller-runtime and controller-tools releases

@zbindenren
Copy link

zbindenren commented May 25, 2022

Just as information. I am developping an operator with go1.18 and k8s 1.24.0. I had problems with controller-gen which paniced. I fixed this issue with the following:

$ go install -v sigs.k8s.io/controller-tools/cmd/controller-gen@master
$ cp $HOME/go/bin/controller-gen $PROJECT_PATH/bin/

Update
I just found out that they released a 0.9.0 version two days ago which works.

@damdo
Copy link
Member

damdo commented May 26, 2022

@AlmogBaku looks like new releases for controller-runtime and controller-tools are both out now.

@camilamacedo86
Copy link
Member Author

camilamacedo86 commented May 26, 2022

We are blocked by: kubernetes-sigs/kubebuilder-declarative-pattern#217 now.
After this one is merged, we are good to move forward.

@bruceherve
Copy link

Hi. for anyone struggling with this issue you can scaffold by using the go/v2 ie run kubebuilder init --plugins go/v2 as you can see,you are using the go/v2 instead of go/v3 plugin..and once you run kubebuilder create api there will be no issue even if you are using Go 1.81..So I guess this allows you to use kubebuilder with Go 1.81 while waiting for the upgrades to be made..

@calvinpark
Copy link

I started a PR in the homebrew-core repo to fix the go version dependency: Homebrew/homebrew-core#102791
I'm new to homebrew formula edits so any help would be appreciated.

@damdo
Copy link
Member

damdo commented Jun 3, 2022

kubernetes-sigs/kubebuilder-declarative-pattern#217 has merged 🎉 cc. @camilamacedo86

@camilamacedo86
Copy link
Member Author

From now on, master branch should support go 1.18

@zbindenren
Copy link

Thx. When is a release planed?

@qingfengfenga
Copy link

#1614
Can't create webhook. Is it related to this problem?

@camilamacedo86
Copy link
Member Author

@qingfengfenga please, open a new issue with your specific problem and providing the details steps to allow us to reproduce it.

@qingfengfenga
Copy link

@camilamacedo86 Sorry, when I checked the version and prepared to reproduce it locally, I found that my document was not the latest (translated version in other languages). After I checked the latest document, using go1.18.1 can complete all functions of cronjob, except testing ( #2642 I found the description of the test problem here). Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet