先安装go,请根据官网选择不同平台进行安装。
Download and install - The Go Programming Language
然后安装kubebuilder
os=$(go env GOOS)
arch=$(go env GOARCH)
export GO111MODULE=on
go get sigs.k8s.io/kubebuilder/cmd/kubebuilder@latest
sudo mv $(go env GOPATH)/bin/kubebuilder /usr/local/bin/
kubebuilder version
我的当前环境如下:
carawang@MacBook-Pro project % kubebuilder version
Version: main.version{KubeBuilderVersion:"4.2.0", KubernetesVendor:"1.31.0", GitCommit:"c7cde5172dc8271267dbf2899e65ef6f9d30f91e", BuildDate:"2024-08-17T09:41:45Z", GoOs:"darwin", GoArch:"amd64"}
carawang@MacBook-Pro project % go version
go version go1.22.0 darwin/amd64