Skip to content

Commit 0defdfc

Browse files
committed
init
Signed-off-by: Ashing Zheng <axingfly@gmail.com>
0 parents  commit 0defdfc

File tree

434 files changed

+68932
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

434 files changed

+68932
-0
lines changed

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.idea/
2+
.vscode/
3+
WORKSPACE
4+
.DS_Store
5+
# don't check in the build output of the book
6+
book/book
7+
8+
# ignore auto-generated dir by `mdbook serve`
9+
src/docs
10+
11+
# Editor temp files
12+
*~
13+
\#*#
14+
*.swp
15+
16+
# Skip bazel dirs
17+
/bazel-*
18+
19+
# skip bin dirs
20+
**/bin
21+
**/testbin
22+
23+
# skip .out files (coverage tests)
24+
*.out
25+
26+
# skip testdata go.sum, since it may have
27+
# different result depending on go version
28+
/testdata/**/go.sum
29+
book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/bin
30+
/testdata/**legacy**
31+
32+
## Skip testdata files that generate by tests using TestContext
33+
**/e2e-*/**

CONTRIBUTING-ROLES.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
Contributing Roles
2+
==================
3+
4+
## Direct Code-Related Roles
5+
6+
While anyone (who's signed the [CLA and follows the code of
7+
conduct](../CONTRIBUTING.md)) is welcome to contribute to the Kubebuilder
8+
project, we've got two "formal" roles that carry additional privileges and
9+
responsibilities: *reviewer* and *approver*.
10+
11+
In a nutshell, reviewers and approvers are officially recognized to make
12+
day-to-day and overarching technical decisions within parts of the
13+
project, or the project as a whole. We follow a similar set of
14+
definitions to the [main Kubernetes project itself][kube-ladder], with
15+
slightly looser requirements.
16+
17+
As much as possible, we want people to help take on responsibility for the
18+
project -- these guidelines are attempts to make it *easier* for this to
19+
happen, *not harder*. If you've got any questions, just reach out on
20+
Slack to one of the [subproject leads][kb-leads] (called
21+
kubebuilder-admins in the `OWNERS_ALIASES` file).
22+
23+
## Prerequisite: Member
24+
25+
Anyone who wants to become a reviewer or approver must first be a [member
26+
of the Kubernetes project][kube-member]. The aforementioned doc has more
27+
details, but the gist is that you must have made a couple of contributions to
28+
some part of the Kubernetes project -- *this includes Kubebuilder and
29+
related repos*. Then, you need two existing members to sponsor you.
30+
31+
**If you've contributed a few times to Kubebuilder, we'll be happy to
32+
sponsor you, just ping us on Slack :-)**
33+
34+
## Reviewers
35+
36+
Reviewers are recognized as able to provide code reviews for parts of the
37+
codebase and are entered into the `reviewers` section of one or more
38+
`OWNERS` files. You'll get auto-assigned reviews for your area of the
39+
codebase and are generally expected to review for correctness,
40+
testing, general code organization, etc. Reviewers may review for design
41+
as well, but approvers have the final say on that.
42+
43+
Things to look for:
44+
45+
- does this code work, and is it written performantly and idiomatically?
46+
- is it tested?
47+
- is it organized nicely? Is it maintainable?
48+
- is it documented?
49+
- does it need to be threadsafe? Is it?
50+
- Take a glance at the stuff for approvers, if you can.
51+
52+
Reviewers' `/lgtm` marks are generally trusted by approvers to means that
53+
the code is ready for one last look-over before merging.
54+
55+
### Becoming a Reviewer
56+
57+
The criteria for becoming a reviewer are:
58+
59+
- Give 5-10 reviews on PRs
60+
- Contribute or review 3-5 PRs substantially (i.e. take on the role of the
61+
defacto "main" reviewer for the PR, contribute a bugfix or feature, etc)
62+
63+
Usually, this will need to occur within a single repository, but if you've
64+
worked on a cross-cutting feature, it's ok to count PRs across
65+
repositories.
66+
67+
Once you meet those criteria, submit yourself as a reviewer in the
68+
`OWNERS` file or files that you feel represent your areas of knowledge via
69+
a PR to the relevant repository.
70+
71+
## Approvers
72+
73+
Approvers provide the final say as to whether a piece of code is merged.
74+
Once approvals (`/approve`) are given for each piece of the affected code
75+
(and a reviewer or approver has added `/lgtm`), the code will merge.
76+
77+
Approvers are responsible for giving the code a final once-over before
78+
merge, and do an overall design/API review.
79+
80+
Things to look for:
81+
82+
- Does the API exposed to the user make sense, and is it easy to use?
83+
- Is it backward compatible?
84+
- Will it accommodate new changes in the future?
85+
- Is it extensible/layer-able (see [DESIGN.md](../DESIGN.md))?
86+
- Does it expose a new type from `k8s.io/XYZ`, and, if so, is it worth it?
87+
Is that piece well-designed?
88+
89+
**For large changes, approvers are responsible for getting reasonable
90+
consensus**. With the power to approve such changes comes the
91+
responsibility of ensuring that the project as a whole has time to discuss
92+
them.
93+
94+
### Becoming an Approver
95+
96+
All approvers need to start as reviewers. The criteria for becoming
97+
an approver is:
98+
99+
- Be a reviewer in the area for a couple of months
100+
- Be the "main" reviewer or contributor for 5-10 substantial (bugfixes,
101+
features, etc) PRs where approvers did not need to leave substantial
102+
additional comments (i.e. where you were acting as a defacto approver).
103+
104+
Once you've met those criteria, you can submit yourself as an approver
105+
using a PR that edits the relevant `OWNERS` files appropriately. The
106+
existing approvers will then approve the change with lazy consensus. If
107+
you feel more comfortable asking before submitting the PR, feel free to
108+
ping one of the [subproject leads][kb-leads] (called kubebuilder-admins in
109+
the `OWNERS_ALIASES` file) on Slack.
110+
111+
## Indirectly Code-Related/Non-Code Roles
112+
113+
We're always looking for help with other areas of the project as well, such
114+
as:
115+
116+
### Docs
117+
118+
Docs contributors are always welcome. Docs folks can also become
119+
reviewers/approvers for the book by following the same process above.
120+
121+
### Triage
122+
123+
Help to triage our issues is also welcome. Folks doing triage are
124+
responsible for using the following commands to mark PRs and issues with
125+
one or more labels, and should also feel free to help answer questions:
126+
127+
- `/kind {bug|feature|documentation}`: things that are broken/new
128+
things/things with lots of words, respectively
129+
130+
- `/triage support`: questions, and things that might be bugs but might
131+
just be confused about how to use something
132+
133+
- `/priority {backlog|important-longterm|important-soon|critical-urgent}`:
134+
how soon we need to deal with the thing (if someone wants
135+
to/eventually/pretty soon/RIGHT NOW OMG THINGS ARE ON FIRE,
136+
respectively)
137+
138+
- `/good-first-issue`: this is pretty straightforward to implement, has
139+
a clear plan, and clear criteria for being complete
140+
141+
- `/help`: this could feasibly still be picked up by someone new-ish, but
142+
has some wrinkles or nitty-gritty details that might not make it a good
143+
first issue
144+
145+
See the [Prow reference](https://prow.k8s.io/command-help) for more
146+
details.
147+
148+
[kube-ladder]: https://github.com/kubernetes/community/blob/master/community-membership.md "Kubernetes Community Membership"
149+
150+
[kube-member]: https://github.com/kubernetes/community/blob/master/community-membership.md#member "Kubernetes Project Member"
151+
152+
[kb-leads]: ../OWNERS_ALIASES "Root OWNERS file -- kubebuilder-admins"

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Running mdBook
2+
3+
The kubebuilder book is served using [mdBook](https://github.com/rust-lang-nursery/mdBook). If you want to test changes to the book locally, follow these directions:
4+
5+
1. Follow the instructions at [https://rust-lang.github.io/mdBook/guide/installation.html](https://rust-lang.github.io/mdBook/guide/installation.html) to
6+
install mdBook.
7+
2. Make sure [controller-gen](https://pkg.go.dev/sigs.k8s.io/controller-tools/cmd/controller-gen) is installed in `$GOPATH`.
8+
3. cd into the `docs/book` directory
9+
4. Run `mdbook serve`
10+
5. Visit [http://localhost:3000](http://localhost:3000)
11+
12+
# Steps to deploy
13+
14+
There are no manual steps needed to deploy the website.
15+
16+
Kubebuilder book website is deployed on Netlify.
17+
There is a preview of the website for each PR.
18+
As soon as the PR is merged, the website will be built and deployed on Netlify.

book/.firebaserc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

book/book.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Kubebuilder 文档站部署说明
2+
3+
本文说明如何在本地构建 `docs/book` 文档站,并将其部署到独立站点。命令与脚本保持仓库现状,不额外引入新依赖。
4+
5+
## 1. 环境准备
6+
7+
- 安装 Go ≥ 1.23(建议与仓库中 `GO_VERSION=1.23.0` 保持一致)。
8+
- 确保 `curl``tar``unzip` 可用,脚本会下载 mdBook 与 `controller-gen`
9+
- 若在 CI 或容器中运行,可使用 `gimme` 预装 Go 版本,以兼容 `install-and-build.sh` 的逻辑。
10+
11+
## 2. 本地构建
12+
13+
所有命令均需在仓库根目录执行:
14+
15+
```bash
16+
GO_VERSION=1.23.0 ./docs/book/install-and-build.sh
17+
```
18+
19+
脚本会:
20+
21+
- 根据当前平台下载 mdBook 0.4.40 至临时目录。
22+
- 安装 `sigs.k8s.io/controller-tools/cmd/controller-gen@v0.19.0``docs/book/functions`
23+
- 运行自定义预处理器 `litgo.sh``markerdocs.sh`
24+
- 输出静态站点到 `docs/book/book`
25+
26+
## 3. 本地预览
27+
28+
构建成功后,可使用任意静态文件服务器本地预览,例如:
29+
30+
```bash
31+
npx serve docs/book/book
32+
```
33+
34+
或使用 Netlify CLI 复现线上行为:
35+
36+
```bash
37+
netlify dev --dir docs/book/book
38+
```
39+
40+
## 4. 独立部署流程
41+
42+
### 4.1 直接同步静态文件
43+
44+
1. 执行构建脚本得到 `docs/book/book` 内容。
45+
2. 同步该目录下的静态文件至目标托管(如 GitHub Pages、S3、Cloudflare Pages、Vercel)。
46+
3. 若平台支持自定义 Header/Redirect,可将 `docs/book/functions` 中的逻辑迁移到对应的 Edge Function 或重写规则,以保留下载链接重定向能力。
47+
48+
### 4.2 Netlify 单独站点
49+
50+
若想在新域名上继续使用 Netlify:
51+
52+
1. 新建 Netlify 站点,仓库指向本项目但使用独立分支或 `docs/book` 子目录。
53+
2. 在站点设置中配置:
54+
- **Base directory**: `docs/book`
55+
- **Build command**: `GO_VERSION=1.23.0 ./install-and-build.sh`
56+
- **Publish directory**: `docs/book/book`
57+
- **Functions directory**: `docs/book/functions`
58+
3. 绑定新域名,配置 HTTPS 即可上线。
59+
60+
## 5. CI/CD 建议
61+
62+
- 在新站点仓库或分支上添加构建流程(如 GitHub Actions),执行同一脚本并发布工件。
63+
- 若构建频次高,建议封装一个包含 Go 与 mdBook 的轻量容器镜像,缩短脚本下载时间。
64+
- 可以引入链接检查、Markdown lint 或 `mdbook build --dest-dir` 的 dry run 以提前发现断链或预处理器错误。
65+
66+
## 6. 常见问题排查
67+
68+
- **mdBook 下载失败**:检查是否被代理阻断,可预先下载并缓存到镜像或内部文件仓库。
69+
- **预处理脚本报错**:确认 `litgo.sh``markerdocs.sh` 拥有执行权限,并在 Bash 环境下运行。
70+
- **Go 依赖缺失**:确保 `GOBIN` 写入路径在 `PATH` 中,或手动导出 `export PATH=$(go env GOBIN):$PATH`
71+
72+
完成上述步骤后,你即可在本地验证文档站,并将同样的构建产物部署到新的独立网站。

book/book.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[book]
2+
authors = ["The Kubebuilder Maintainers"]
3+
multilingual = false
4+
src = "src"
5+
title = "The Kubebuilder Book"
6+
7+
[output.html]
8+
smart-punctuation = true
9+
additional-css = ["theme/css/markers.css", "theme/css/custom.css", "theme/css/version-dropdown.css"]
10+
git-repository-url = "https://github.com/kubernetes-sigs/kubebuilder"
11+
edit-url-template = "https://github.com/kubernetes-sigs/kubebuilder/edit/master/docs/book/{path}"
12+
13+
[preprocessor.literatego]
14+
command = "./litgo.sh"
15+
16+
[preprocessor.markerdocs]
17+
command = "./markerdocs.sh"
18+
19+
[context.environment]
20+
environment = { GO_VERSION = "1.23" }
21+
22+
[context.deploy-preview.environment]
23+
environment = { GO_VERSION = "1.23" }
24+

book/functions/handle-version.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function notFound(info) {
2+
return {
3+
statusCode: 404,
4+
headers: {'content-type': 'text/html'},
5+
body: ("<h1>Not Found</h1>"+
6+
"<p>You shouldn't see this page, please file a bug</p>"+
7+
`<details><summary>debug details</summary><pre><code>${JSON.stringify(info)}</code></pre></details>`
8+
),
9+
};
10+
}
11+
12+
function redirectToDownload(version, file) {
13+
const loc = `https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${version}/${file}`;
14+
return {
15+
statusCode: 302,
16+
headers: {'location': loc, 'content-type': 'text/plain'},
17+
body: `Redirecting to ${loc}`,
18+
};
19+
}
20+
21+
22+
exports.handler = async function(evt, ctx) {
23+
// grab the prefix too to check for coherence
24+
const [prefix, version, os, arch] = evt.path.split("/").slice(-4);
25+
if (prefix !== 'releases' || !version || !os || !arch) {
26+
return notFound({version: version, os: os, arch: arch, prefix: prefix, rawPath: evt.path});
27+
}
28+
29+
switch(version[0]) {
30+
case '1':
31+
// fallthrough
32+
case '2':
33+
return redirectToDownload(version, `kubebuilder_${version}_${os}_${arch}.tar.gz`);
34+
default:
35+
return redirectToDownload(version, `kubebuilder_${os}_${arch}`);
36+
}
37+
}

0 commit comments

Comments
 (0)