I am trying to build out my Custom Resource project in Kubebuilder but it seems like I am missing my controller gen whenever I build it out. I keep getting the error:
/Users/*****/Kubernetes/postgres-writer-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
bash: /Users/****/Kubernetes/postgres-writer-operator/bin/controller-gen: No such file or directory
make: *** [generate] Error 127
Error: failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2
Usage:
kubebuilder create api [flags]
I am new to Kubernetes and am following the tutorial below: https://yash-kukreja-98.medium.com/develop-on-kubernetes-series-operator-dev-understanding-and-dissecting-kubebuilder-4321d3ecd7d6
First I ran the following command that bootstraps my project:
kubebuilder init \
--domain yash.com \
--repo github.com/yashvardhan-kukreja/postgres-writer-operator \
--project-name postgres-writer-operator \
--license apache2 \
--skip-go-version-check
After running the command I went into my directory and found the following files and folders:
Then the next step was to run bootstrapper for my custom resource PostgresWriter and attach it to the operator.
kubebuilder create api \
--group demo \
--version v1 \
--kind PostgresWriter \
--resource true \
--controller true \
--namespaced true
This resulted in the error listed above. How do I generate my controller gen using kubebuilder? Is there a step I am missing here?
FYI by go version is 1.18.
I faced a similar issue and resetting my go version to v1.17.* helped me resolve the issue.
Step 1: Uninstall go by finding out where go is located
$ which go
Step 2: Remove any go related paths from PATH environment variable
Step 3: Re install go using the pkg in this link.
Try all your kubebuilder steps once again after go installation is complete.