This blog post is about how you could save time, when you are starting to setup your development environment for a GO operator with the Operator SDK on a macOS, in combination with Visual Studio Code.
Please take also a look in the blog post make: *** [generate] Error 127, which is currently related to that topic.
Maybe you started already with GO and you have installed GO with the normal GO installation for macOS. I mean you didn’t use the brew package manager for the first GO installation and you maybe also have configured environment variables like the
export GOPATH=/usr/local/go export GOROOT=$GOPATH/bin
Example steps to create an operator API using the Operator SDK:
operator-sdk init --domain example.net --repo github.com/yourproject/youroperator
- Create API
operator-sdk create api --group yourgroup --version v1alpha1 --kind yourcrd --resource --controller
Again the error:
FATA failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2
When you start to find solutions for that error on Google, the error message guides you to an access rights problem.
In my case I figured out that the root cause for the error is that the Operator SDK installation was done with brew, which installed the needed GO version for the Operator SDK. That could create the situation that you have two versions of GO installed, which do have different configurations, which can create an access rights problem.
The simple solution in that situation is:
These are the steps which maybe can help you in that situation.
Step 1: Ensure you have a clean system:¶
brew uninstall operator-sdk brew uninstall go sudo rm -rf /usr/local/Cellar/go sudo rm -rf /usr/local/go sudo rm -rf /Users/YOUR_USER/go
Step 2: Install the Operator SDK using brew¶
Again: That will install the Operator SDK and the related GO working version!
brew install operator-sdk
Step 3: Verify the installed packages¶
brew list | grep "go" brew list | grep "operator-sdk"
Step 4: Ensure there is no remaining cache from your previous installation¶
sudo go clean -cache
Step 5: Install/reinstall the GO extension to Visual Studio Code¶
Now, you should be ready to go!
Note: By the way if you are new to GO, you should just install GO and use it, and don’t customize any environment variables if you don’t exactly know what you are doing ;-).
I hope this was useful for you and let’s see what’s next?
#operator, #brew, #go, #operatorsdk, #macos, #operatorlearningjourney