kubebuilder: etcd should not be assumed to be in /usr/local/kubebuilder/bin/etcd

I installed the Kubebuilder binaries in a personal folder:

/usr/local/home/cflewis/bin/kubebuilder/etcd

Kubebuilder assumes that etcd is in /usr/local/kubebuilder/bin/etcd

$ make test
go generate ./pkg/... ./cmd/...
go fmt ./pkg/... ./cmd/...
go vet ./pkg/... ./cmd/...
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
CRD manifests generated under '/usr/local/home/cflewis/src/go/src/github.com/cflewis/kubebuilder-demo/config/crds' 
RBAC manifests generated under '/usr/local/home/cflewis/src/go/src/github.com/cflewis/kubebuilder-demo/config/rbac' 
go test ./pkg/... ./cmd/... -coverprofile cover.out
?       github.com/cflewis/kubebuilder-demo/pkg/apis    [no test files]
?       github.com/cflewis/kubebuilder-demo/pkg/apis/ships      [no test files]
2018/07/20 14:11:56 fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory
FAIL    github.com/cflewis/kubebuilder-demo/pkg/apis/ships/v1beta1      0.199s
?       github.com/cflewis/kubebuilder-demo/pkg/controller      [no test files]
2018/07/20 14:11:56 fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory
FAIL    github.com/cflewis/kubebuilder-demo/pkg/controller/sloop        0.186s
?       github.com/cflewis/kubebuilder-demo/cmd/manager [no test files]
Makefile:9: recipe for target 'test' failed
make: *** [test] Error 1

My grepping found this:

./vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:  defaultEtcdBin          = "/usr/local/kubebuilder/bin/etcd"

As long as etcd is in the user’s path, things should work. Is there a reason a full path was hardcoded?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 12
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

kubebuilder needs to be unzipped or linked to default directory which is ‘/usr/local/kubebuilder’ as instructed in document. Kubebuilder uses binaries from it

I saw the same error when I ran make test in the workspace created using kubebuiler due to missing /usr/local/kubebuilder/bin/etcd file on the host:

go test ./api/... ./controllers/... -coverprofile cover.out
...
2019-05-22T16:25:21.837Z	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 0, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}

The following steps resolved the error for me and then make test worked fine:

wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.0.0-alpha.1/kubebuilder_2.0.0-alpha.1_linux_amd64.tar.gz
tar -zxvf  kubebuilder_2.0.0-alpha.1_linux_amd64.tar.gz
sudo mv kubebuilder_2.0.0-alpha.1_linux_amd64 /usr/local/kubebuilder

$ find /usr/local/kubebuilder
/usr/local/kubebuilder
/usr/local/kubebuilder/bin
/usr/local/kubebuilder/bin/etcd
/usr/local/kubebuilder/bin/kube-apiserver
/usr/local/kubebuilder/bin/kubebuilder
/usr/local/kubebuilder/bin/kubectl

workspace_directory$ make test
go fmt ./...
go vet ./...
go test ./api/... ./controllers/... -coverprofile cover.out
ok  	redacted/api/v1alpha1	7.420s	coverage: 2.4% of statements
ok  	redacted/controllers	5.816s	coverage: 0.0% of statements

Please consider adding the information to

export KUBEBUILDER_ASSETS = <path of kubebuilder/bin>

in the kubebuilder book.

You can also set the KUBEBUILDER_ASSETS environment variable, for posterity

We can use setup-envtest tool to download which version of assets we need and use like below:

export KUBEBUILDER_ASSETS=$(setup-envtest use 1.25.0 -p path)

export KUBEBUILDER_ASSETS=<path of kubebuilder/bin>

probably remove the “space” on the both sides of the equal sign will be better

With this commit https://github.com/kubernetes-sigs/controller-runtime/commit/c5e5439a4953c1a2cab7975cab74cedc0dde3da2 (which is included at least in 1.0.5) we can use the envvar KUBEBUILDER_ASSETS to pass the bin-directory explicitly.

export KUBEBUILDER_ASSETS=~/sdk/kubebuilder_1.0.5_linux_amd64/bin/

Worked for me with the getting-started example (Except for struggling because of #359).

Yes, I also find this rather very surprising.

That sounds okay to me, shall we close?

On Fri, 19 Oct 2018, 2:36 pm Christoph Glaubitz, notifications@github.com wrote:

With this commit kubernetes-sigs/controller-runtime@c5e5439 https://github.com/kubernetes-sigs/controller-runtime/commit/c5e5439a4953c1a2cab7975cab74cedc0dde3da2 (which is included at least in 1.0.5) we can use the envvar KUBEBUILDER_ASSETS to pass the bin-directory explicitly.

export KUBEBUILDER_ASSETS=~/sdk/kubebuilder_1.0.5_linux_amd64/bin/

Worked for me with the getting-started example (Except for struggling because of #359 https://github.com/kubernetes-sigs/kubebuilder/issues/359).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kubernetes-sigs/kubebuilder/issues/326#issuecomment-431365391, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPWS6QC5weX16_2ZzmfFz5NysSXGYmIks5umdVVgaJpZM4VZR0S .