-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
📖 Add Go section to install clusterctl #11464
Conversation
Signed-off-by: sivchari <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Ah, sorry. Presumably, we can't embed the some versions via ldflags option if we use |
An alternative would be to make clusterctl not fail when the ld flags have not been set. Afaik they are only used for the version subcommand (which should be okay) and as post run to check for new versions. |
I think it's prefer the way you propose. So I'd open the issue to discuss about it. |
Test to ensure the version you installed is up-to-date: | ||
```bash | ||
clusterctl version |
There was a problem hiding this comment.
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"}
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarification :-)
What this PR does / why we need it:
I added the Go section to install clusterctl via go install.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
/area documentation