Skip to content

Commit 533cb30

Browse files
authored
Merge pull request #293 from pwittrock/v1.0
GitBook updates for 1.0
2 parents feba3a3 + b832f34 commit 533cb30

24 files changed

+655
-832
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
run: gitbook-1-0
6+
name: gitbook-1-0
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
run: gitbook-1-0
12+
template:
13+
metadata:
14+
labels:
15+
run: gitbook-1-0
16+
spec:
17+
containers:
18+
- image: gcr.io/kubebuilder/book1.0
19+
imagePullPolicy: Always
20+
name: gitbook

build/gitbook/config/service_new.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
run: gitbook-1-0
6+
name: gitbook-1-0
7+
spec:
8+
ports:
9+
- port: 80
10+
protocol: TCP
11+
targetPort: 80
12+
selector:
13+
run: gitbook-1-0
14+
type: LoadBalancer

docs/book/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{% panel style="info", title="Under Development" %}
2-
This book is being actively developed.
3-
{% endpanel %}
4-
51
**Note:** Impatient readers head straight to [Quick Start](quick_start.md).
62

73
*To share this book use the icons in the top-right of the menu.*

docs/book/SUMMARY.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414

1515
* Development Workflow
1616
* [Project Creation and Structure](basics/project_creation_and_structure.md)
17-
* Resource Fundamentals
17+
* Resources
1818
* [What is a Resource](basics/what_is_a_resource.md)
19-
* [Simple Resource Example](basics/simple_resource.md)
20-
* Controller Fundamentals
19+
* [Resource Example](basics/simple_resource.md)
20+
* Controllers
2121
* [What is a Contoller](basics/what_is_a_controller.md)
22-
* [Simple Controller Example](basics/simple_controller.md)
23-
* [Controller Watch Functions](basics/controller_watches.md)
24-
* [Creating Events](basics/creating_events.md)
25-
* Controller-Manager Fundamentals
26-
* [What is the Controller-Manager](basics/what_is_the_controller_manager.md)
27-
* [Simple Controller-Manager](basics/simple_controller_manager.md)
22+
* [Controller Example](basics/simple_controller.md)
23+
* Managers
24+
* [What is the Manager](basics/what_is_the_controller_manager.md)
25+
* [Manager Example](basics/simple_controller_manager.md)
2826

2927
### Beyond the Basics
3028

@@ -35,6 +33,8 @@
3533
* [Updating Kubebuilder](beyond_basics/upgrading_kubebuilder.md)
3634
* Controllers
3735
* [Controllers For Core Resources](beyond_basics/controllers_for_core_resources.md)
36+
* [Controller Watch Functions](beyond_basics/controller_watches.md)
37+
* [Creating Events](beyond_basics/creating_events.md)
3838

3939

4040
### Reference Docs
Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,53 @@
1-
{% panel style="info", title="Under Development" %}
2-
This book is being actively developed.
3-
{% endpanel %}
4-
51
# Project Creation and Structure {#project-creation-and-structure}
62

73
## Go package Structure
84

9-
Kubebuilder projects contain 4 important packages.
5+
Kubebuilder projects contain 3 important packages.
106

117
##### cmd/...
128

13-
The `cmd` package contains the controller-manager main program which runs controllers. Users typically
14-
will not need to modify this package unless they are doing something special.
9+
The `cmd` package contains the manager main program. Manager is responsible for initializing
10+
shared dependencies and starting / stopping Controllers. Users typically
11+
will not need to edit this package and can rely on the scaffolding.
12+
13+
The `cmd` package is scaffolded automatically by `kubebuilder init`.
1514

1615
##### pkg/apis/...
1716

18-
The `pkg/apis/...` packages contains the *go* structs that define the resource schemas.
19-
Users edit `*_types.go` files under this director to implement their API definitions.
17+
The `pkg/apis/...` packages contains the API resource definitions.
18+
Users edit the `*_types.go` files under this director to implement their API definitions.
2019

2120
Each resource lives in a `pkg/apis/<api-group-name>/<api-version-name>/<api-kind-name>_types.go`
2221
file.
2322

24-
For more information on API Group, Version and Kinds, see the *What is a Resource* chapter.
25-
26-
{% panel style="info", title="Generated code" %}
27-
Kubebuilder will generate boilerplate code required for Resources by running
28-
`kubebuilder generate`. The generated files are named `zz_generated.*`.
29-
{% endpanel %}
23+
The `pkg/apis` package is scaffolded automatically by `kubebuilder create api` when creating a Resource.
3024

3125
##### pkg/controller/...
3226

33-
The `pkg/controller/...` packages contain the *go* types and functions that implement the
34-
business logic for APIs in *controllers*.
27+
The `pkg/controller/...` packages contain the Controller implementations.
28+
Users edit the `*_controller.go` files under this directory to implement their Controllers.
29+
30+
The `pkg/controller` package is scaffolded automatically by `kubebuilder create api` when creating a Controller.
3531

36-
More information on Controllers in the *What is a Controller* chapter.
32+
## Additional directories and files
3733

38-
##### pkg/inject/...
34+
In addition to the packages above, a Kubebuilder project has several other directories and files.
3935

40-
The `pkg/inject/...` packages contain the generated code that registers annotated
41-
Controllers and Resources.
36+
##### Makefile
4237

43-
*Note*: This package is unique to kubebuilder.
38+
A Makefile is created with targets to build, test, run and deploy the controller artifacts
39+
for development as well as production workflows
4440

45-
## Additional directories
41+
##### Dockerfile
4642

47-
In addition to the packages above, a Kubebuilder project has several other directories.
43+
A Dockerfile is scaffolded to build a container image for your Manager.
4844

49-
##### hack/...
45+
##### config/...
5046

51-
Kubebuilder puts miscellaneous files into the hack directory.
47+
Kubebuilder creates yaml config for installing the CRDs and related objects under config/.
5248

53-
- API installation yaml
54-
- Samples resource configs
55-
- Headers for generated files: `boilerplate.go.txt`
49+
- config/crds
50+
- config/manager
5651

5752
##### docs/...
5853

@@ -71,7 +66,7 @@ that will be required to build your project.
7166

7267
{% sample lang="bash" %}
7368
```bash
74-
$ kubebuilder init --domain k8s.io
69+
$ kubebuilder init --domain k8s.io --license apache2 --owners "The Kubernetes Authors"
7570
```
7671
{% endmethod %}
7772

@@ -85,12 +80,12 @@ and [What Is A Controller](../basics/what_is_a_controller.md)
8580

8681
{% sample lang="bash" %}
8782
```bash
88-
$ kubebuilder create resource --group mygroup --version v1beta1 --kind MyKind
83+
$ kubebuilder create api --group mygroup --version v1beta1 --kind MyKind
8984
```
9085
{% endmethod %}
9186

9287
{% method %}
93-
## Run your controller-manager locally against a Kubernetes cluster
88+
## Run your manager locally against a Kubernetes cluster
9489

9590
Users may run the controller-manager binary locally against a Kubernetes cluster. This will
9691
install the APIs into the cluster and begin watching and reconciling the resources.
@@ -100,19 +95,21 @@ install the APIs into the cluster and begin watching and reconciling the resourc
10095
# Create a minikube cluster
10196
$ minikube start
10297

103-
# Install the APIs into the minikube cluster and begin watching it
104-
$ GOBIN=${PWD}/bin go install ${PWD#$GOPATH/src/}/cmd/controller-manager
105-
$ bin/controller-manager --kubeconfig ~/.kube/config
98+
# Install the CRDs into the cluster
99+
$ make install
100+
101+
# Build and run the manager
102+
$ make run
106103
```
107104
{% endmethod %}
108105

109106
{% method %}
110-
## Create an object
107+
## Create an instance
111108

112-
Create a new instance of your Resource. Observe the controller-manager logs after creating the object.
109+
Create a new instance of your Resource. Observe the manager logs printed to the console after creating the object.
113110

114111
{% sample lang="bash" %}
115112
```bash
116-
$ kubectl apply -f hack/sample/<resource>.yaml
113+
$ kubectl apply -f sample/<resource>.yaml
117114
```
118115
{% endmethod %}

0 commit comments

Comments
 (0)