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

📖 Add Go section to install clusterctl #11464

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/book/src/user/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,20 @@ Test to ensure the version you installed is up-to-date:
clusterctl.exe version
```

{{#/tab }}
{{#tab Go}}

#### Install clusterctl with Go
Install the latest version of clusterctl using Go:
```bash
go install sigs.k8s.io/cluster-api/cmd/clusterctl@latest
```

Test to ensure the version you installed is up-to-date:
```bash
clusterctl version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this work for you?

It didn't for me:

$ go install sigs.k8s.io/cluster-api/cmd/clusterctl@latest
go: downloading sigs.k8s.io/cluster-api v1.9.3

$ ~/code/bin/clusterctl version
clusterctl version: &version.Info{Major:"", Minor:"", GitVersion:"", GitCommit:"", GitTreeState:"", BuildDate:"", GoVersion:"go1.22.1", Compiler:"gc", Platform:"darwin/arm64"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply.

It didn't for me, too.

Expected

clusterctl version: &version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"cd279dd0c24c5472db45255e3805ae16c61e1432", GitTreeState:"clean", BuildDate:"2024-12-23T13:13:07Z", GoVersion:"go1.22.10", Compiler:"gc", Platform:"darwin/arm64"}

Actual

clusterctl version: &version.Info{Major:"", Minor:"", GitVersion:"", GitCommit:"", GitTreeState:"", BuildDate:"", GoVersion:"devel go1.24-ccf4ebbb61 Wed Dec 4 04:10:56 2024 +0000", Compiler:"gc", Platform:"darwin/arm64"}

But it work when I pass the ldflags like this

go install  -ldflags "-X 'sigs.k8s.io/cluster-api/version.gitMajor=1' -X 'sigs.k8s.io/cluster-api/version.gitMinor=9'" sigs.k8s.io/cluster-api/cmd/clusterctl@latest
clusterctl version: &version.Info{Major:"1", Minor:"9", GitVersion:"", GitCommit:"", GitTreeState:"", BuildDate:"", GoVersion:"devel go1.24-ccf4ebbb61 Wed Dec 4 04:10:56 2024 +0000", Compiler:"gc", Platform:"darwin/arm64"}

Of course, I still didn't get the GitCommit etc.

Should I rewrite this section or remove it ?

Copy link
Member

@sbueringer sbueringer Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if there is a way to make the "simple" go install work (including the correct version). Do we know if that works with some other projects and if yes, what they do differently?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK both kubectl and kubeadm do not support installing with go install

TBH, I would prefer to not support go install vs supporting it with cryptic -ldflags or knowing it leads to wrong version

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: with go install the debug.ReadBuildInfo() get's populated which contains a .Main.Version.

In case of go build this normally contains (devel), so its useless.

But when using go install [email protected] it contains vx.x.x.
In case of using go isntall module@CommitHash it contains e.g. v0.0.0-20250108155011-73ddd0ddd442.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But: I'd prefer to not add this to the documentation as it leads to binaries built differently and we don't have the bandwidth to support this.

@sivchari is there a strong use case over not using the pre-compiled released binaries?

We make sure that the pre-built and released binaries are built with the right go version and these binaries get tested in CI too (for linux amd64).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @chrischdi
Thank you for good feedback. Honestly, I don't have strong use case. I usually use go install to get the binary. Thus I noticed it, but as @fabriziopandini and you said, I thought that it's better not to have various way to install clusterctl, too.
So I close this PR since I change my mind not to add this document.
Thanks all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification :-)

```

{{#/tab }}
{{#/tabs }}

Expand Down