注意:go版本和kubebuilder版本需要兼容 如下go env 参数一定要修改 CGO_ENABLED="0" GO111MODULE="on" 本机环境 centos 7.9 amd64, go1.17 和kubebuilder v3.4.1 一、下载安装 (1)安装 kubebuilder wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.4.1/kubebuilder_linux_amd64 mv kubebuilder_linux_amd64 kubebuilder chmod +x kubebuilder && mv kubebuilder /usr/local/bin/ (2)安装kustomize curl -Lo ./kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.2.0/kustomize_3.2.0_linux_amd64 chmod +x ./kustomize sudo mv kustomize /usr/local/bin 二、初始化 kubebuilder init --domain cloud.com --owner "yuanqh" --skip-go-version-chec 三、创建api kubebuilder create api --group hft --version v1 --kind VirtualMachine
1.遇到的错误提示:
/usr/local/go/src/net/cgo_linux.go:13:8: no such package located
Error: not all generators ran successfully
run `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./... -w` to see all available markers, or `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./... -h` for usage
make: *** [Makefile:48: generate] Error 1
Error: failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2
浏览/usr/local/go/src/net/cgo_linux.go:13:8:
解决办法:CGO_ENABLED="0"
标签:kustomize,amd64,--,kubebuilder,linux,go,安装 From: https://www.cnblogs.com/zxqblogrecord/p/16992997.html