operator-sdk环境搭建
我的电脑环境为windows,安装operator-sdk需要自己编译构建二进制文件。
参考官方文档Compile and install from master
官方给的Prerequisites为:
- git
- mercurial version 3.9+
- bazaar version 2.7.0+
- go version v1.13+.
其中mercurial和bazaar我都没装,operator-sdk也编译安装成功了。
$ go get -d github.com/operator-framework/operator-sdk # This will download the git repository and not install it
$ cd $GOPATH/src/github.com/operator-framework/operator-sdk
$ git checkout master
$ make tidy
$ make install
- 测试是否完成安装
$ operator-sdk version
operator-sdk version: "v0.15.0-33-ga1a9cbba", commit: "a1a9cbba09cb05914704c3229bc6df3f86269a56", go version: "go1.13.7 windows/amd64"
使用operator-sdk
仍然参考官方文档
$ cd $GOPATH/src/
$ export GO111MODULE=on && export GOPROXY=https://goproxy.io
$ operator-sdk new operator-demo
time="2020-02-11T16:39:13+08:00" level=info msg="Creating new Go operator 'operator-demo'."
time="2020-02-11T16:39:13+08:00"