Skip to content

Commit 52ba0c3

Browse files
committed
New Book
This introduces a new version of the book. The initial portion is built around a tutorial building the cronjob controller. It now uses [mdbook](https://crates.io/crates/mdbook), which is like gitbook but maintained and written in rust. We've got a custom "plugin" (executable) that slurps Go files into book pages for parts of the tutorial (look for `{{#literatego ./path/to/thing}}`).
1 parent e46e06e commit 52ba0c3

Some content is hidden

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

69 files changed

+8690
-76
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.idea/
22

3-
# Not check in node_modules to a specific arch and os.
4-
docs/book/node_modules/
3+
# don't check in the build output of the book
4+
docs/book/book/
55

66
# Editor temp files
77
*~

build/thirdparty/brodocs/Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

build/thirdparty/brodocs/runbrodocs.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/book/book.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/book/book.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[book]
2+
authors = ["The Kubebuilder Maintainers"]
3+
multilingual = false
4+
src = "src"
5+
title = "The Kubebuilder Book"
6+
7+
[output.html]
8+
google-analytics = "UA-119864590-1"
9+
curly-quotes = true
10+
11+
[preprocessor.literatego]
12+
command = "./litgo.sh"

docs/book/install-and-build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
os=$(go env GOOS)
4+
arch=$(go env GOARCH)
5+
6+
# grab mdbook
7+
# mdbook's deploy got borked by a CI move, so grab our build till that gets
8+
# fixed (https://github.com/rust-lang-nursery/mdBook/issues/904).
9+
curl -sL -o /tmp/mdbook https://storage.googleapis.com/kubebuilder-build-tools/mdbook-0.2.3-${os}-${arch}
10+
chmod +x /tmp/mdbook
11+
/tmp/mdbook build

docs/book/litgo.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
(
6+
pushd ./utils
7+
go build -o ../../../bin/literate-go ./literate.go
8+
popd
9+
) &>/dev/null
10+
11+
../../bin/literate-go "$@"

docs/book/src/SUMMARY.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Summary
2+
3+
[Introduction](./introduction.md)
4+
5+
[Quick Start](./quick-start.md)
6+
7+
---
8+
9+
- [Tutorial: Building CronJob](./cronjob-tutorial.md)
10+
11+
- [What's in a basic project?](./cronjob-tutorial/basic-project.md)
12+
- [Every journey needs a start, every program a main](./cronjob-tutorial/empty-main.md)
13+
- [Groups and Versions and Kinds, oh my!](./cronjob-tutorial/gvks.md)
14+
- [Adding a new API](./cronjob-tutorial/new-api.md)
15+
- [Designing an API](./cronjob-tutorial/api-design.md)
16+
17+
- [A Brief Aside: What's the rest of this stuff?](./cronjob-tutorial/other-api-files.md)
18+
19+
- [What's in a controller?](./cronjob-tutorial/controller-overview.md)
20+
- [Implementing a controller](./cronjob-tutorial/controller-implementation.md)
21+
22+
- [You said something about main?](./cronjob-tutorial/main-revisited.md)
23+
24+
- [Running and deploying the controller](./cronjob-tutorial/running.md)
25+
- [Epilogue](./cronjob-tutorial/epilogue.md)
26+
27+
---
28+
29+
[Appendix: The TODO Landing Page](./TODO.md)

docs/book/src/TODO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# TODO
2+
3+
If you're seeing this page, it's probably because something's not done in
4+
the book yet. Go [see if anyone else has found
5+
this](https://github.com/kubernetes-sigs/kubebuilder/issues?q=is%3Aopen+is%3Aissue+label%3Akind%2Fdocumentation)
6+
or [bug the
7+
maintainers](https://github.com/kubernetes-sigs/kubebuilder/issues/new?assignees=&labels=kind%2Fdocumentation).

docs/book/src/cronjob-tutorial.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Tutorial: Building CronJob
2+
3+
Too many tutorials start out with some really contrived setup, or some toy
4+
application that gets the basics across, and then stalls out on the more
5+
complicated suff. Instead, this tutorial should take you through (almost)
6+
the full gamut of complexity with Kubebuilder, starting off simple and
7+
building up to something pretty full-featured.
8+
9+
Let's pretend (and sure, this is a teensy bit contrived) that we've
10+
finally gotten tired of the maintenance burden of the non-Kubebuilder
11+
implementation of the CronJob controller in Kuberntes, and we'd like to
12+
rewrite it using KubeBuilder.
13+
14+
The job (no pun intended) of the *CronJob* controller is to run one-off
15+
tasks on the Kubernetes cluster at regular intervals. It does the by
16+
bulding on top of the *Job* controller, whose task is to run one-off tasks
17+
once, seeing them to completion.
18+
19+
Instead of trying to tackle rewriting the Job controller as well, we'll
20+
use this as an opportunity to see how to interact with external types.
21+
22+
## Scaffolding Out Our Project
23+
24+
As covered in the [quick start](./quick-start.md), we'll need to scaffold
25+
out a new project. Make sure you've [installed
26+
Kubebuilder](./quick-start.md#installation), then scaffold out a new
27+
project:
28+
29+
```bash
30+
# we'll use a domain of tutorial.kubebuilder.io,
31+
# so all API groups will be <group>.tutorial.kubebuilder.io.
32+
kubebuilder init --domain tutorial.kubebuilder.io
33+
```
34+
35+
Now that we've got've a project in place, let's take a look at what
36+
Kubebuilder has scaffolded for us so far...

0 commit comments

Comments
 (0)