kubebuilder构建一个云原生开放平台

初始化项目

$ kubebuilder init
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.7.0
go: downloading sigs.k8s.io/controller-runtime v0.7.0
go: downloading k8s.io/apimachinery v0.19.2
go: downloading k8s.io/client-go v0.19.2
go: downloading k8s.io/utils v0.0.0-20200912215256-4140de9c8800
go: downloading github.com/go-logr/logr v0.3.0
go: downloading k8s.io/component-base v0.19.2
go: downloading github.com/prometheus/procfs v0.1.3
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.0.1
go: downloading k8s.io/api v0.19.2
go: downloading golang.org/x/net v0.0.0-20200707034311-ab3426394381
go: downloading k8s.io/klog/v2 v2.2.0
go: downloading github.com/imdario/mergo v0.3.10
go: downloading golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4
go: downloading google.golang.org/protobuf v1.24.0
go: downloading golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
go: downloading golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
go: downloading github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7
go: downloading github.com/googleapis/gnostic v0.5.1
go: downloading k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6
go: downloading k8s.io/apiextensions-apiserver v0.19.2
Update go.mod:
$ go mod tidy
go: downloading github.com/onsi/ginkgo v1.14.1
go: downloading golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
go: downloading go.uber.org/goleak v1.1.10
go: downloading github.com/Azure/go-autorest/autorest v0.9.6
go: downloading cloud.google.com/go v0.51.0
go: downloading github.com/Azure/go-autorest/autorest/adal v0.8.2
Next: define a resource with:
$ kubebuilder create api

创建 api:

$ kubebuilder create api --group tensorbytes --version v1 --kind AIServer
Create Resource [y/n]
y
Create Controller [y/n]
y

如果在 windows 下需要安装 make 命令

shikanon wechat
欢迎您扫一扫,订阅我滴↑↑↑的微信公众号!