-
MODULE=example.com/foo-controller
-
go mod init $MODULE
-
kubebuilder init --domain example.com
-
kubebuilder edit --multigroup=true
- 这一步可以使kubebuilder生成的api目录结构与code-generator保持一致
-
kubebuilder create api --group webapp --version v1 --kind Guestbook
-
添加文件apis/webapp/v1/rbac.go,这个文件用生成RBAC manifests:
// +kubebuilder:rbac:groups=webapp.example.com,resources=guestbooks,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=webapp.example.com,resources=guestbooks/status,verbs=get;update;patch package v1
-
make manifests
-
make install 安装到本地集群
-
code-generator生成client
. └── hack ├── tools.go ├── update-codegen.sh └── verify-codegen.sh # tools.go // +build tools package tools import _ "k8s.io/code-generator" # hack/update-codegen.sh 注意 MODULE和go.mod保持一致 API_PKG=apis,和apis目录保持一致 OUTPUT_PKG=generated/webapp,生成Resource时指定的group一样 GROUP_VERSION=webapp:v1和生成Resource时指定的group version对应 # hack/verify-codegen.sh # 下载code-generator 注意这里的K8S版本号,得和go.mod里的k8s.io/client-go的版本一致: K8S_VERSION=v0.23.0 go get k8s.io/code-generator@$K8S_VERSION go mod vendor # 执行 ./hack/update-codegen.sh 得到example.com/foo-controller目录: example.com/foo-controller/generated直接移出来,放到项目根下面pkg下
kubebuilder-test's Introduction
kubebuilder-test's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.